title: How to use the camera calibration in opencv to measure real world coordinates from pixels
body: <p>I already have read 3 books form the topic</p>
  
  <ul>
  <li>Practical OpenCV - Smarth Brahmbhat</li>
  <li>Learning OpenCV - O'Reilly</li>
  <li>OpenCV 2 Computer Vision Application Programing Cookbook - Robert Laganière</li>
  </ul>
  
  <p>I already do the calibration processes and I have the all the return parameters after calibration, like:</p>
  
  <ul>
  <li>Camera Matrix</li>
  <li>Distortion coefficients</li>
  <li>Extrinsic parameters</li>
  </ul>
  
  <p>I ran a program to take this data. This program is in the OpenCV tutorials, in the section "calib3d module. Camera calibration and 3D reconstruction"</p>
  
  <p>I am going to describe the process, I put a fixed camera looking for the floor and the chessboard in front of the camera. I took 15 pictures of the chessboard moving it and the last picture the chessboard is on the floor with inclination 0º.</p>
  
  <p>A several books talk to use this formula to convert real word coordinates to pixels.</p>
  
  <p><a href="https://www.dropbox.com/s/o77drhopfqgqju6/Captura%20de%20pantalla%20de%202015-03-09%2010%3A44%3A52.png?dl=0" rel="nofollow">Formula to get pixels from real word coordinates</a><a href="https://www.dropbox.com/s/o77drhopfqgqju6/Captura%20de%20pantalla%20de%202015-03-09%2010%3A44%3A52.png" rel="nofollow">https://www.dropbox.com/s/o77drhopfqgqju6/Captura%20de%20pantalla%20de%202015-03-09%2010%3A44%3A52.png</a></p>
  
  <p>The translation and rotation matrix is 3 rows x 4 cols but the extrinsic parameters are 15 rows x 6 cols, one per picture taken. I use the last one row. I have read and have found that the 3 first cols correspond to the rotations coefficients and the last 3 cols to translation coefficients but the rotation matrix are 3x3 so I use the function <strong>cv::Rodrigues</strong> to convert it to 3x3 and I put it with a col next to returned cv::Mat from cv::Rodrigues (I read this from <strong>Learning OpenCV - O'Reilly</strong>).</p>
  
  <p>So, I need pixels to real world coordinates, not backward. So I applied the Cramer Rule to get X and Y, but its return me with out sense points, like 0,0 pixels are -4,-3 in real world.</p>
  
  <p>I am asking how to get real world coordinates from pixels in the right way. I hope have been clear</p>