Another quick question: How does the center of mass function (from the OpenNI user generator) map to a coordinate for X and Y direction? My first thought was that it maps the center of a blob to [-resolution/2, resolution/2] for both x and y so the center of the camera image is at (0,0) and the top right corner coordinate is (320, 240) if the resolution is 640x480.
But when I try it out, the mapping seems to work a bit different. The top image is correct but the bottom one is positioned outside the blob (I remapped the center of mass to [0,640] and [0,480] for the (x,y) coordinate).Edit:
Ok, I fixed the problem. The UserGenerator::GetCoM() returned a real world coordinate. I needed to project it to screen coordinates using a function from the DepthGenerator:
recordDepth.getXnDepthGenerator().ConvertRealWorldToProjective(1, &com, &com);
int x = com.X;
int y = com.Y;