ofxKinectCommonBridge icon indicating copy to clipboard operation
ofxKinectCommonBridge copied to clipboard

Incorrect mapping of depth to color

Open thibautvdu opened this issue 10 years ago • 1 comments

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.

thibautvdu avatar Aug 05 '14 09:08 thibautvdu

Cool! Can you submit a pull request for it?

joshuajnoble avatar Aug 10 '14 05:08 joshuajnoble