Pixel 4正面摄像头上的WebCamTexture始终是夜视(黑白)

Pixel 4正面摄像头上的WebCamTexture始终是夜视(黑白)

我什至在设备默认的相机应用中找不到此设置。在Unity中,我有一个应用程序,我只是在使用WebCamTexture并将其显示在四边形上。后置摄像头很好。全彩色,但是当我将其设置为前置摄像头时,它是黑白的,就像卡在某种红外夜视模式中一样。

统一版本2018.3.7 设备:Pixel 4 XL(无法正常工作) Pixel 2 XL(适用于彩色图像)

有没有统一的东西可以解决这个问题?

我已经尝试了统一文档中的所有内容,但是没有设置。

IEnumerator initAndWaitForWebCamTexture(){
        isInitWaiting = true;

        devices = WebCamTexture.devices;
        webCams = new WebCamTexture[devices.Length];
        textures = new Texture[devices.Length];

        for (int i = 0; i < devices.Length; i++)
        {
            webCams[i] = new WebCamTexture();
            webCams[i] = new WebCamTexture(devices[i].name,Mathf.RoundToInt(requestResolution.x),Mathf.RoundToInt(requestResolution.y),30);
            textures[i] = webCams[i];
            textures[i].wrapMode = TextureWrapMode.Repeat;

            if (useFrontCam)
            {
                if (devices[i].isFrontFacing)
                {
                    TargetcamID = i;
                }
            }
            else
            {
                if (!devices[i].isFrontFacing)
                {
                    TargetcamID = i;
                }
            }
        }
        if (TargetcamID > devices.Length - 1) TargetcamID = devices.Length - 1;

        texture = webCams[TargetcamID];
        webCams[TargetcamID].requestedFPS = 30;
        webCams[TargetcamID].Play();

        for (int i = 0; i < materials.Length; i++)
        {
            materials[i].mainTexture = textures[TargetcamID];
        }
        if (BackgroundQuad != null) BackgroundQuad.getcomponent<Renderer>().material.mainTexture = textures[TargetcamID];

        foreach (GameObject obj in targetMeshObjects)
        {
            obj.getcomponent<Renderer>().material.mainTexture = textures[TargetcamID];
        }

        if (textures.Length > 0)
        {
            webCamTexture = webCams[TargetcamID];
            int initFrameCount = 0;
            bool isTimeout = false;

            while (webCamTexture.width <= 16)
            {
                if (initFrameCount > timeoutFrameCount)
                {
                    isTimeout = true;
                    break;
                }
                else
                {
                    initFrameCount++;
                }
                yield return new WaitForEndOfFrame();
            }

            textureResolution = new Vector2(webCamTexture.width,webCamTexture.height);

            isFlipped = webCamTexture.videoVerticallyMirrored;

            isInitWaiting = false;
        }
        yield return null;
    }

使用相同代码的像素2可以正确显示相机。因此,这与Pixel 4的摄像头有关,但似乎还没有人遇到过这种情况。

leoyyc1987 回答:Pixel 4正面摄像头上的WebCamTexture始终是夜视(黑白)

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3141921.html

大家都在问