buffer - Vuforia & Unity readpixels frame



Past month i've been working with Unity and Vuforia to create an Augmented Reality game for android/tablet. I've been working with a unity-pro trial and since today i've got a full unity pro license. Now i don't know if it has to do with the change from trial to full, but ever since i'm getting the error:

ReadPixels was called to read pixels from system frame buffer, while not inside drawing frame. UnityEngine.Texture2D:ReadPixels(Rect, Int32, Int32, Boolean) WebCamImpl:GetPixels32AndBufferFrame(Int32) (at Assets/Qualcomm Augmented Reality/Scripts/Internal/WebCamImpl.cs:250) QCARManagerImpl:InjectCameraFrame() (at Assets/Qualcomm Augmented Reality/Scripts/Internal/QCARManagerImpl.cs:452) QCARManagerImpl:Update(ScreenOrientation) (at Assets/Qualcomm Augmented Reality/Scripts/Internal/QCARManagerImpl.cs:195) QCARBehaviour:Update() (at Assets/Qualcomm Augmented Reality/Scripts/QCARBehaviour.cs:418)


Trying to read pixel out of bounds

Leaving me unable to run the game in the editor. It works fine when i build it towards my android or switch platform to pc. But that takes lots of time and i really want to keep bugtesting in the editor instead of building everytime i would like to test something new.

I've tried lots of things already (complete new projects, exporting and importing packages and added a external webcam as well).

(Also: im getting a Webcam profile nog found! error from the WebCamBehaviour script, might have something to do with it)

Thanks in advance,


1 Answer: 

You must use WaitForEndOfFrame() before use ReadPixels(). Like here:

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);