Closed Uralstech closed 8 months ago
I have fixed this issue using a RenderTexture:
// Get a temporary RenderTexture
RenderTexture rt = RenderTexture.GetTemporary(_webCamTexture.width, _webCamTexture.height, 0, RenderTextureFormat.ARGB32);
// Copy _webCamTexture to rt
Graphics.Blit(_webCamTexture, rt);
// Set the active RenderTexture to rt
RenderTexture.active = rt;
// Create a new Texture2D in ARGB32 format
Texture2D newTexture = new Texture2D(_webCamTexture.width, _webCamTexture.height, TextureFormat.ARGB32, false);
// Read the pixels from the RenderTexture and apply
newTexture.ReadPixels(new Rect(0, 0, _webCamTexture.width, _webCamTexture.height), 0, 0);
newTexture.Apply();
// Reset the active RenderTexture
RenderTexture.active = null;
RenderTexture.ReleaseTemporary(rt);
Hi!
Thank you for this great plugin! This was just what I was looking for.
Environment
Issue
I have a simple script which uses the USB camera footage and converts it from ARGB32 to RGBA32. It was not working, so while debugging, I decided to try saving the copied frame to local storage. When I check the storage all I find is a blank, greyish translucent image.
The peculiar part is that in my preview RawImage, (
_cameraPreviewImage
), the Texture appears fine! In a different test, I also tried displaying the copied frame (_webCamTextureCopy
), which also displayed fine!Code