title: Kinect, using depth image to get Z value
body: <p>I am trying to figure out how to detect an object and it's X,Y,Z position in real world using Kinect's RGB and Depth camera.</p>
  
  <p>I read this question: <a href="https://stackoverflow.com/questions/17832238/kinect-intrinsic-parameters-from-field-of-view/18199938#18199938">Kinect intrinsic parameters from field of view</a></p>
  
  <p>To apply this, I need Xv, Yv, and Zw..</p>
  
  <p>So far, I have successfully detected an object from the RGB camera (Xv,Yv position on screen), but I am not sure how to get the Zw value from the depth camera "correctly".</p>
  
  <p>Here is the picture of the object that I'm detecting (right: only RGB, left: RGB+Depth overlay)
  <img src="https://i.stack.imgur.com/1PHfD.png" alt="Snapshot"></p>
  
  <p>The red object detection rectangle on the right window is perfectly fine, but on the left window, the rectangle has slightly drifted away from the depth image. That means that I cannot simply read the value at (Xv, Yv) from Depth camera and use it as Zw value.</p>
  
  <p>P.S. I'm using freenect and opencv on Ubuntu</p>
  
  <p>Please help me figure out how to get the object's Z position.</p>