WebCamTexture на фронтальной камере Pixel 4 - это всегда ночное видение (черно-белое) - PullRequest
1 голос
/ 07 ноября 2019

enter image description here Я даже не могу найти этот параметр в приложении камеры по умолчанию для устройств. В Unity у меня есть приложение, которое я просто использую WebCamTexture и отображаю на четырехугольнике. Задняя камера в порядке. Полноцветный, но когда я устанавливаю его на фронтальную камеру, он становится черно-белым, словно застрял в каком-то режиме ИК ночного видения.

Unity Version 2018.3.7 Устройство: Pixel 4 XL (не работает правильно) Pixel 2 XL (правильно работает с цветным изображением)

Есть ли что-нибудь для единства, которое может это исправить?

Я попробовал все в документации по Unity, но для этого нет настроек.

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, но, похоже, никто еще не сталкивался с этим.

...