unity 获取摄像头图片被旋转处理

使用的是 unity 2018.2.18f1   设备小米6

问题:摄像头捕获出来的图像显示到图片上被旋转了90度

解决方案:旋转承载图片(RawImage_Camera) rotation( z = -90)

注意:我在截取图像的时候高宽是正常设置的 因为图像被旋转在设置图片(RawImage_Camera)时将宽高对调了的 

 

代码:

    public string deviceName;
    private WebCamTexture WCTexture = null;

        //标准 为 1242*2688
        float f = Screen.height / 2688f;

        //申请打开摄像头权限
        yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
        if (Application.HasUserAuthorization(UserAuthorization.WebCam)) {
            WebCamDevice[] devices = WebCamTexture.devices;
            //var deviceName = "";
            if (devices.Length > 0) {
                deviceName = devices[0].name;
            }
            WCTexture = new WebCamTexture(deviceName, (int)(Screen.width * f), Screen.height, 12);
            WCTexture.wrapMode = TextureWrapMode.Repeat;
            //将摄像头类容实时传输到RawImage上
            RawImage_Camera.GetComponent().texture = WCTexture;
            //打开摄像头
            WCTexture.Play();  
        }

 

//摄像头使用完成后注意关闭

//关闭摄像头
        if (WCTexture != null) {
            WCTexture.Pause();
        }

unity 获取摄像头图片被旋转处理_第1张图片

你可能感兴趣的:(unity 获取摄像头图片被旋转处理)