Aligning color with depth
The steps to implement the green screen have now changed because of the alignment problem of color and depth images. Instead of directly blending the depth and color images, we will first construct a new texture for storing remapped colors (and use the player index to subtract the background colors). Then we will display the new texture on screen, which can be treated as the result of background removal.
Generating a color image from depth
This time we will use an inbuilt Kinect API method to align the color data with depth and combine them again. Let's start now:
Now we will have to traverse all pixels and save the color values where the player index is valid (for others, we set the color to total black). This requires a new texture object, which is named
playerColorTexture
here:TextureObject* colorTexture = NULL; TextureObject* playerColorTexture = NULL;
The
playerColorTexture
is in RGBA format, so we can use its alpha channel for image masking, besides the RGB components...