使用WebCamTexture的WebCamTexture.GetPixels()方法从相机获取照片时,偶尔会出现“图像撕裂”,从而在图像中创建“偏移线”。我会说我有5%的时间看到了这一点。当有运动发生时,我会更注意到它,但我偶尔也会注意到静止镜头。
有人知道如何解决这个问题吗?
(我正在将其部署到Android和iOS,因此使用VR照片捕获库或Windows照片捕获库无法解决我的问题)
下面是我已经采取的一些缓解措施(这似乎有点过分),但这仍然不能解决图像撕裂问题。我最初的想法是,当我获取像素时,网络摄像头试图渲染自己,所以我暂停了网络摄像头以测试这一理论,但这仍然无法完成任务。
下面的第一张图片是我一直期待的,第二张图片有上面描述的图像撕裂。
// pause the webcam texture MyWebCamTexture.Pause(); // wait until we can see that it is no longer playing yield return new WaitUntil(CameraIsntPlaying()); // wait for the fixed update for good measure yield return new WaitForFixedUpdate(); // wait until end of frame yield return new WaitForEndOfFrame(); // get the pixels var pix = MyWebCamTexture.GetPixels(); // set the pixels to the texture textureRef.SetPixels(pix); // apply textureRef.Apply();
好图片坏图片