Saving Tango Camera Data As An Image
I'd like to save the camera data from the Tango camera as an image file. I'm not sure where to start, the closest question I could find is this: Getting Tango's camera stream data
Solution 1:
Your script should inherit ITangoVideoOverlay and implement OnTangoImageAvailableEventHandler where the image is stored under TangoUnityImageData imageBuffer as a byte array (imageBuffer.data). The image is in YUV format so you will have to convert it to RGB or some another format.
privatevoidSaveImage(byte[] byteArray, string datetime)
{
...
TextureFormatformat= TextureFormat.RGBA32;
Texture2Dx=newTexture2D(1920, 1080, format, false);
Color32[] argbArray = ColorHelper.YUV_NV21_TO_RGB(byteArray, 1920, 1080);
x.SetPixels32(argbArray);
File.WriteAllBytes(PATH + datetime + "_image.jpg", x.EncodeToJPG());
...
}
Of course, size shouldn't be hard coded but this is just work in progress (imageBuffer has values for width and height).
Post a Comment for "Saving Tango Camera Data As An Image"