Using Kinect2.0 's Multisourceframereader, get Depthframesource, Colorframesource, Bodyindexframesource, and get the corresponding frame.
hr = Pmykinect->openmultisourceframereader (framesourcetypes::framesourcetypes_depth | | Framesourcetypes::framesourcetypes_bodyindex, &pmultisourceframereader);
Through the spatial mapping, the color space is mapped to the depth space because the Bodyindex space and depth space are the same, so the color pixels mapped to the depth space can be processed directly. The details look directly at the code.
hr = Pcoordinatemapper->mapcolorframetodepthspace (Depthheight * depthwidth, (uint16*) PDepthBuffer, ColorHeight * Colorwidth, pdepthcoordinates);
Code Address:
Https://github.com/stone-ch/kinect2-opencv3/tree/master/KinectChangeBackground
Without uploading the project files, the environment I am using is:
Kinect SDK v2.0_1409 64-bit
Opencv3.1.0
VS2013
Win10
:
PS: The background image is 1920 * 1080, because the image captured by the Kinect's color camera is this size.
What needs to be improved: smoothing the character edges and blending the foreground background.
Reference:
Http://blog.csdn.net/column/details/bbdxf-kinectv2.html
http://blog.csdn.net/qq_22033759/article/category/5617829
C:\Program Files\Microsoft Sdks\kinect\v2.0_1409\samples\native\coordinatemappingbasics-d2d Kinect SDK comes with an example, This is the path on your computer.
Kinect SDK2.0 + OpenCV 3.0 keying, background change