none
RGB image based on depth data RRS feed

  • Question

  • I am trying to display original colour on desired parts of the image based on the depth data. For example, if the subject is within certain boundary of depth(z-value), I want to display it with original colour and the rest of the frame which are out of boundary should be displayed as black or anything else. So far, I could only get it displayed in a single colour, not original color data. The code below will display those in boundary with RED colour. After going through some forums, i noticed there is a parameter 'GetColorPixelCoordinatesFromDepthPixel' in SDK. But this is not shown in the SDK that I installed (SDK v1.0). Any guidance on how to go about this would be much appreciated. Here's the code that I currently have.

                    DepthImageFrame depthframe = _sensor.DepthStream.OpenNextFrame(0);
                        if (depthframe != null)
                        {                                                
                            short[] depthArray = depthframe.ToDepthArray();
                            
                            byte[] depthBytes = new byte[depthArray.Length * 4];
    
                            for (int colorIndex = 0, depthIndex = 0;
                                colorIndex < depthBytes.Length;
                                colorIndex += 4, depthIndex++)
                            {
                                depthBytes[colorIndex + GREEN_INDEX] = 0;
                                depthBytes[colorIndex + BLUE_INDEX] = 0;
    
                                if (depthArray[depthIndex] > _minDepth &&
                                    depthArray[depthIndex] < _maxDepth)
                                {
                                   
                                   depthBytes[colorIndex + RED_INDEX] = 255;
    
                                }
                                else
                                    depthBytes[colorIndex + RED_INDEX] = 0;
                            }
    
                            source = depthBytes.ToBitmapSource(depthframe.Width, depthframe.Height);

    Saturday, August 4, 2012 6:46 AM

All replies