【问题标题】:Vuforia & Unity readpixels frameVuforia 和 Unity 读取像素帧
【发布时间】:2013-05-14 09:42:37
【问题描述】:

上个月,我一直在与 Unity 和 Vuforia 合作,为安卓/平板电脑创建增强现实游戏。我一直在使用 unity-pro 试用版,从今天开始我已经获得了完整的 unity pro 许可证。现在我不知道这是否与从试用到完整的更改有关,但是自从我收到错误以来:

调用 ReadPixels 以从系统帧缓冲区读取像素,而不是在绘图帧内。 UnityEngine.Texture2D:ReadPixels(Rect, Int32, Int32, Boolean) WebCamImpl:GetPixels32AndBufferFrame(Int32) (在 Assets/Qualcomm Augmented Reality/Scripts/Internal/WebCamImpl.cs:250) QCARManagerImpl:InjectCameraFrame() (在 Assets/Qualcomm Augmented Reality /Scripts/Internal/QCARManagerImpl.cs:452) QCARManagerImpl:Update(ScreenOrientation) (在 Assets/Qualcomm Augmented Reality/Scripts/Internal/QCARManagerImpl.cs:195) QCARBehaviour:Update() (在 Assets/Qualcomm Augmented Reality/Scripts/ QCARBehaviour.cs:418)

和

试图读取像素越界

让我无法在编辑器中运行游戏。当我将它构建到我的 android 或将平台切换到 pc 时,它工作正常。但这需要很多时间,我真的想在编辑器中继续进行错误测试,而不是每次我想测试新东西时都进行构建。

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

(另外:我找到了一个网络摄像头配置文件!WebCamBehaviour 脚本中的错误,可能与它有关)

提前致谢,

特威

【问题讨论】:

    标签: buffer unity3d frame pixels vuforia


    【解决方案1】:

    您必须在使用 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();}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多