"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

Can't read pixel values from VideoBackgroundTexture on Android build

Good day.

We're trying to get the RGB values of the Vuforia background image, took by the camera.

We get the background image by doing this:

Texture renderText;
renderText = VuforiaRenderer.Instance.VideoBackgroundTexture;
Texture2D Text2D = renderText as Texture2D;

or this:

GameObject Go = GameObject.Find("BackgroundPlane");
MeshRenderer MR = Go.GetComponent<MeshRenderer>();
Texture2D Text2D = MR.materials[0].mainTexture as Texture2D;

After this, we can assign this Texture 2D as the texture of a UI Raw Image and it works properly on every platform.

When we try to read its pixel values

Color32[] cols = Text2D.GetPixels32();
string n = "";
for (int i = 0; i < 5; i++)
n += cols[i]; print(n);

the Unity Editor will successfully return the color of the given pixel - for example "RGBA(110, 130, 143, 225)". However, an Android build will always return "RBA(0, 0, 0, 0)".

Do you know a way around this problem?

Thank you.

This should be doable and seems like a Unity issue. I'm guessing it has something to do with compression format on the original render texture.  Android probably can't read directly off of some formats.