none
Creating opposite Mirror picture by manipulate Kinect Color pixel RRS feed

  • Question

  • Hi,

    I tring to create an opposite mirror picture from the color stream, i.e., when right hand is moving up, i want that kinect will draw the left hand 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 { 
                
                
                }
            }


    Thursday, August 15, 2013 1:02 PM

Answers