C# 像素4'上的网络摄像头纹理;s-前置摄像头始终为夜视(黑白)
我甚至在设备默认摄像头应用程序中找不到此设置。在Unity中,我有一个应用程序,我正在使用WebCamTexture并将其显示在一个四边形上。后面的照相机很好。全彩,但当我把它设置为前向摄像头时,它是黑白的,就像它被某种红外夜视模式卡住了一样 Unity版本2018.3.7 设备:像素4 XL(无法正常工作) 像素2 XL(适用于彩色图像) 有没有什么团结可以解决这个问题 我已经尝试了unity文档中的所有内容,但是没有设置C# 像素4'上的网络摄像头纹理;s-前置摄像头始终为夜视(黑白),c#,unity3d,google-pixel,C#,Unity3d,Google Pixel,我甚至在设备默认摄像头应用程序中找不到此设置。在Unity中,我有一个应用程序,我正在使用WebCamTexture并将其显示在一个四边形上。后面的照相机很好。全彩,但当我把它设置为前向摄像头时,它是黑白的,就像它被某种红外夜视模式卡住了一样 Unity版本2018.3.7 设备:像素4 XL(无法正常工作) 像素2 XL(适用于彩色图像) 有没有什么团结可以解决这个问题 我已经尝试了unity文档中的所有内容,但是没有设置 IEnumerator initAndWaitForWebCamTex
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;
}
IEnumerator initAndWaitForWebCamTexture(){
isInitWaiting=true;
设备=WebCamTexture.devices;
网络摄像头=新的网络摄像头纹理[devices.Length];
纹理=新纹理[devices.Length];
对于(int i=0;idevices.Length-1)TargetCamID=devices.Length-1;
纹理=网络摄像头[TargetCamID];
网络摄像头[TargetCamID].requestedFPS=30;
网络摄像头[TargetCamID].Play();
对于(int i=0;i0)
{
webCamTexture=网络摄像头[TargetCamID];
int initFrameCount=0;
bool isTimeout=false;
while(webCamTexture.width timeoutFrameCount)
{
isTimeout=true;
打破
}
其他的
{
initFrameCount++;
}
返回新的WaitForEndOfFrame();
}
textureResolution=新矢量2(webCamTexture.width、webCamTexture.height);
isFlipped=webCamTexture.VideoVerticalyMirrored;
isInitWaiting=false;
}
收益返回空;
}
使用相同代码的像素2正确显示相机。因此,这与Pixel 4的摄像头有关,但似乎还没有人遇到过这一问题。请提供一些图像。添加了屏幕快照设备的功能是什么。长度返回?因此我没有访问前摄像头,它是面部红外摄像头。但是Unity只能看到后面的摄像头和红外摄像头,而不能看到前面的摄像头。我找到了一个临时的解决方案,直到我明白我到底在抓取哪个设备。因为isFrontFacing似乎首先返回TargetCamID作为红外摄像机设备编号,但当TargetCamID设置为0时,它返回的是正确的前向摄像机。