1

I want to calculate the z coordinate of an object relative to the camera (kinect), knowing the information of depth from the kinect. I know also the intrinsic parameters.

Any help is much appreciated. Thanks!

Paul
  • 167
  • 1
  • 2
  • 11

1 Answers1

0

If you want the real world measurements (including depth), you want to retrieve the point cloud map, something like:

Mat world;
if( capture.retrieve(world, CV_CAP_OPENNI_POINT_CLOUD_MAP)){
Vec3f pt3D = world.at<Vec3f>(yourY, yourX);
cout << "pt3D" << pt3D << endl;
}

Notice that you pass the y first, then the x. I've learned that somewhat recently :)

Community
  • 1
  • 1
George Profenza
  • 50,687
  • 19
  • 144
  • 218
  • But cout << "pt3D " << pt3D[2] give me the same value of depthMap.at (y,x). Instead, I want the value along the z coordinate camera – Paul Oct 16 '12 at 13:34
  • As far as I can tell the OpenNI grabber returns the [x,y,z position in meters](https://code.ros.org/trac/opencv/browser/trunk/opencv/modules/highgui/src/cap_openni.cpp?rev=4926#L482) for the POINT_CLOUD_MAP. Is that not what you need ? – George Profenza Oct 16 '12 at 13:43
  • I tried to select two pixels: (310,80) and (310,80) but I had pt3D1[2]=1.014 and pt3D2[2]=1.052 instead they must be the same – Paul Oct 16 '12 at 14:14
  • you can try to use putText to draw coordinates in your output image/matrix, but assuming (310,80) is a valid depth pixel and the object in realife at that location doesn't move (nor the kinect), depth values will be around the same, but not exactly the same. From what I hear, if you check a depth value using an Asus sensor, the depth value for the same pixel will remain stable. I haven't experienced that with the kinect though...depth always seems to 'flicker' a bit around a value – George Profenza Oct 16 '12 at 15:21