UVC4UnityAndroid
UVC4UnityAndroid copied to clipboard
How to get the byte[] raw data callback in NV21 format?
How to get the byte[] raw data callback in NV21 format?
I need to obtain byte[] data in RGB888 or NV21 format. However, the UVC plug-in only provides callbacks with Texture type parameters. I need to convert Texture to Texture2D every frame, which is very time-consuming. So I want to ask how to get the byte[] callback in NV21 format directly from UVC?
UVC...Callback(Texture tex);
...
...
...
Texture2D destTex2D = new Texture2D(width, height, TextureFormat.RGB24, false, false);
RenderTexture tmpRenderTexture = RenderTexture.GetTemporary(width, height, 32);
RenderTexture currentRT = RenderTexture.active;
Graphics.Blit(tex, tmpRenderTexture);
RenderTexture.active = tmpRenderTexture;
destTex2D.ReadPixels(new Rect(0, 0, width, height), 0, 0);
RenderTexture.active = currentRT;
Color32[] colors = destTex2D.GetPixels32();