- Home /
Kinect color frame - texture format bug
Hi everyone. I'm work on unity5 personal edition with kinect v.1 and I have incorrect mapping TextureFormat. I receive color frame from kinect sensor, create Texture2D with (frame.Width, frame.Height, TextureFormat.RGBA32) and save it. But the image colors has offset, blue color is not on right place. Using different TextureFormat (for 32 bits) not fix my problem.
public class ColorFrame
{
public ColorFrame();
public byte[] Data { get; set; }
public int Height { get; set; }
public int Width { get; set; }
}
void Update ()
{
ColorFromKinect(frame);
}
private void ColorFromKinect(ColorFrame frame)
{
if (ReceiveColorFrame != null && (ReceiveColorFrame.height != frame.Height || ReceiveColorFrame.width != frame.Width))
{
ReceiveColorFrame = new Texture2D(frame.Width, frame.Height, TextureFormat.RGBA32, false);
gameObject.GetComponent<MeshRenderer>().material.mainTexture = ReceiveColorFrame;
}
else if (ReceiveColorFrame == null)
{
ReceiveColorFrame = new Texture2D(frame.Width, frame.Height, TextureFormat.RGBA32, false);
gameObject.GetComponent<MeshRenderer>().material.mainTexture = ReceiveColorFrame;
}
ReceiveColorFrame.LoadRawTextureData(frame.Data);
ReceiveColorFrame.Apply();
}
Comment