Edit: As in the AlexColgan response, it's impossible to retrieve the original pair of images from the yuy2 one. There is a need to have access to the raw bytes.
Hello everyone !
I'm currently using the Leap Motion in UVC mode and can retrieve the raw interleaving green/magenta distorted image. But I can't get how to transform it into the left and right image in grayscale (like what we got with the leap sdk).
I understand from the manual on github that it's 8 bit interleaving images and pixel are alternate (left and right image). But when I'm try to convert it, the result isn't the right one... Below are my attempt in Unity. I think that my problem is maybe due to the image format (RGB 16 in input and RGB24 in output)... I'm a little lost and don't know exactly what to try...
Thanks in advance,
void Compute() {
byte[] bytes = _texture.GetRawTextureData(); // image
Texture2D leftRight = new Texture2D(_texture.width, _texture.height, TextureFormat.RGB24, false);
int width = _texture.width;
int height = _texture.height;
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
int idx = 2 * (j * width + i);
byte b = bytes[idx];
float f = b / 255f;
leftRight.SetPixel(i, j, new Color(f,f,f));
}
}
leftRight.Apply();
GetComponent<RawImage>().texture = leftRight;
}