ofxKinectCommonBridge
ofxKinectCommonBridge copied to clipboard
Incorrect mapping of depth to color
Hi there ! Thanks for your great work.
I couldn't get a proper alignment by setting true to the function initDepthstream
so I did some changes.
I think the mapping routine in the update method might be wrong and the result of the method INuiCoordinateMapper::MapDepthFrameToColorFrame
might have been misunderstood as the comment // if mapping depth to color, upscale depth
point it. The result argument pColorPoints
(cf doc) map a depth image index with a color image position and not a depth image index with a depth image position.
Thus :
depthPixels[i] = depthLookupTable[ ofClamp(depthPixelsRaw[pts[i].y * depthFormat.dwWidth + pts[i].x] >> 4, 0, depthLookupTable.size()-1 ) ];
Should be :
int colorImageIndex = pts[i].y * depthFormat.dwWidth + pts[i].x;
depthPixels[colorImageIndex] = depthLookupTable[ofClamp(depthPixelsRaw[i] >> 4, 0, depthLookupTable.size() - 1)];
If I do not mistake, you can have a look at my fork. The result seems correct for my usage, yet the accuracy is not satisfactory. I am looking for a way to use the background segmentation from the toolkit in OF now.
Cool! Can you submit a pull request for it?