Vuforia& Unity readpixels框架

时间:2013-05-14 09:42:37

标签: buffer unity3d frame pixels vuforia

上个月我一直在与Unity和Vuforia合作,为Android /平板电脑创建一个增强现实游戏。我一直在进行团结专业试验,从今天起我已经获得了完整的团结专业许可证。现在我不知道它是否与从试验到完整的变化有关,但自从我收到错误后:

调用ReadPixels来读取系统帧缓冲区中的像素,而不是在绘图框内。 UnityEngine.Texture2D:ReadPixels(Rect,Int32,Int32,Boolean)WebCamImpl:GetPixels32AndBufferFrame(Int32)(在Assets / Qualcomm增强现实/脚本/内部/ WebCamImpl.cs:250)QCARManagerImpl:InjectCameraFrame()(在Assets / Qualcomm增强现实中) /Scripts/Internal/QCARManagerImpl.cs:452)QCARManagerImpl:Update(ScreenOrientation)(在Assets / Qualcomm增强现实/脚本/内部/ QCARManagerImpl.cs:195)QCARBehaviour:Update()(在Assets / Qualcomm增强现实/脚本/ QCARBehaviour.cs:418)

尝试读取超出范围的像素

让我无法在编辑器中运行游戏。当我构建它到我的Android或切换平台到PC时它工作正常。但这需要花费大量时间,而且我真的想在编辑器中继续进行错误测试,而不是每次我想测试一些新的东西时进行构建。

我已经尝试了很多东西(完成新项目,导出和导入包以及添加外部网络摄像头)。

(另外:我发现了一个Webcam配置文件nog!来自WebCamBehaviour脚本的错误,可能与它有关)

提前致谢,

Twei

1 个答案:

答案 0 :(得分:0)

在使用ReadPixels()之前,必须使用WaitForEndOfFrame()。 像这里:

private IEnumerator RPixels(){
    yield return new WaitForEndOfFrame();
    // Create a texture the size of the screen, RGB24 format
    int width = Screen.width;
    int height = Screen.height;
    Texture2D tex = new Texture2D(width, height, TextureFormat.RGB24, false);
    // Read screen contents into the texture
    tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
    tex.Apply();}