ofxOpenNI 2.0 XYZ coordinates from depth map

I just changed from ofxOpenNI 1.0 to 2.0 and can’t figure out how to get x,y,z coordinates from the depth map. I want to do a hot box collision test. Help please…

I found a solution for those of you who may be curious…

ofMesh & mesh = user.getPointCloud();

vector XYZ = mesh.getVertices();
for (vector::iterator i = XYZ.begin(); i != XYZ.end(); i++) {
ofCircle(i->x, i->y, i->z, 20);

Is there a better way to do this?

are you using the openni version 2.0 or is that you are using ofxOpenNI2?
anyways, how are you getting the depth image to the ofMesh? you can skip the ofMesh and get directly the depth values to iterate over.
It should be quite straight forward.

That’s what I can’t seem to find. A simple call to get the x,y,z points directly would be helpful. Im using ofxOpenNI2…

To get the ofxMesh, there is a helper function that returns a mesh.

ofMesh m = user->getPointCloud();  

I guess that based on the current API this is the only way~

hi, it’s much easier than that.
juts get the depth image, using ofxOpenNIDevice.getDepthRawPixels(); (you must activate first the raw pixels by calling ofxOpenNIDevice.setUseDepthRawPixels(true):wink: or you can also use ofxOpenNIDevice.getDepthPixels(). I recomend using raw pixels (this are the real values given by the depth camera).
The value of the pixel is it’s depth or Z axis position, and the pixel position is the x and y values.