Frame from ZEDRenderingPlane is always grey

Hi, I am trying to get the frame from the ZEDCamera but I am facing the problem that I always get a grey image as output. What I do is call TextureEye from the ZEDRendering plane, because as I understood it should always contain the current frame. Can you please tell me why I always get this grey output?

Hi,

Do you see the camera images when playing any example scene, for ex “Simple_MR”?

Also, are you trying to save it on disk?

I can see the camera images when playing a scene.
Yes, I am trying to save it on disk, is this the problem?

I see why it is confusing and I’ll definitely change that ASAP but the “TextureEye” texture only exist on GPU and is not accessible on CPU.

You can either use the “RetrieveImage” function instead, but you will need to call it for each camera grab or use the following code snippet to make TextureEye available on CPU, to be saved on disk.

This is a relatively slow process.

        RenderTexture currentActiveRT = RenderTexture.active;
        RenderTexture rt = new RenderTexture(TextureEye.width, TextureEye.height, 0, RenderTextureFormat.ARGB32);
        Graphics.Blit(TextureEye, rt);

        // Set the supplied RenderTexture as the active one
        RenderTexture.active = rt;

        // Create a new Texture2D and read the RenderTexture image into it
        Texture2D tex = new Texture2D(rt.width, rt.height);
        tex.ReadPixels(new Rect(0, 0, tex.width, tex.height), 0, 0);

        // Restore previously active render texture
        RenderTexture.active = currentActiveRT;

Thanks a lot! Is it possible to “convert” the ZEDMat to a Unity Texture2D?

This function does it : zed-unity/ZEDCamera/Assets/SDK/Helpers/Scripts/ObjectDetection/DetectedBody.cs at master · stereolabs/zed-unity · GitHub

You might need to slightly change it to match your texture format.

1 Like