Thursday, 15 August 2013

Creating oposite Mirror picture by manipulate Kinect Color pixels

Creating oposite Mirror picture by manipulate Kinect Color pixels

I tring to create an opposite mirror picture from teh color stream, i.e.,
when right hand is moving up, i want that kinect will draw the left had to
move up (unlike infront of real mirror that the right hand is raising )i
want to manipulate the color image to do that: just moving the X position.
However, i got blue screen :
void kinectSensor_ColorFrameReady(object sender,
ColorImageFrameReadyEventArgs e) { try { using (ColorImageFrame
colorImageFrame = e.OpenColorImageFrame()) { if (colorImageFrame != null)
{ byte[] pixelsFromFrame = new byte[colorImageFrame.PixelDataLength];
colorImageFrame.CopyPixelDataTo(pixelsFromFrame); Color[] color = new
Color[colorImageFrame.Height * colorImageFrame.Width]; kinectRGBVideo =
new Texture2D(graphics.GraphicsDevice, colorImageFrame.Width,
colorImageFrame.Height);
// Go through each pixel and set the bytes correctly
// Remember, each pixel got a Rad, Green and Blue
int index = 0;
for (int y = 0; y < colorImageFrame.Height; y++)
{
for (int x = 0; x < colorImageFrame.Width; x++,
index += 4)
{
color[(y * colorImageFrame.Width + x)] = new
Color(pixelsFromFrame[(y+1)*(2560 -index)],
pixelsFromFrame[(y + 1) * (2560 - index)],
pixelsFromFrame[(y + 1) * (2560 - index)]);
}
}
// Set pixeldata from the ColorImageFrame
to a Texture2D
kinectRGBVideo.SetData(color);
}
}
}
catch {
}
}
Can anyone tell me what is worng ? Thanks erez

No comments:

Post a Comment