UVC4UnityAndroid icon indicating copy to clipboard operation
UVC4UnityAndroid copied to clipboard

How to get the byte[] raw data callback in NV21 format?

Open boostcat opened this issue 1 year ago • 1 comments

How to get the byte[] raw data callback in NV21 format?

boostcat avatar Feb 27 '24 10:02 boostcat

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

boostcat avatar Feb 27 '24 10:02 boostcat