title: Meaning of the retval return value in cv2.CalibrateCamera
body: <p>as the title says, my question is about a return value given by the calibrateCamera function from OpenCv.</p>
  
  <p><a href="http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html" rel="noreferrer">http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html</a></p>
  
  <p>I have a functionnal implementation in python to find the intrinsic parameters and the distorsion coefficients of a Camera using a Black&amp;White grid. </p>
  
  <p>The question is more about the retval returned by the function. If i understood correctly it is the "the average re-projection error. This number gives a good estimation of precision of the found parameters. This should be as close to zero as possible." as mentionned in </p>
  
  <p><a href="http://docs.opencv.org/doc/tutorials/calib3d/camera_calibration/camera_calibration.html" rel="noreferrer">http://docs.opencv.org/doc/tutorials/calib3d/camera_calibration/camera_calibration.html</a></p>
  
  <p>What exactly does a value close as close to zero as possible mean?</p>
  
  <p>For example when i do it for my Logitech webcam:</p>
  
  <p>RMS: <code>0.702660793513</code></p>
  
  <p>camera matrix:</p>
  
  <pre><code>[[ 616.30868126    0.          339.02126978]
   [   0.          605.08224927  241.64607568]
   [   0.            0.            1.        ]]
  </code></pre>
  
  <p>Distortion coefficients:  </p>
  
  <pre><code>[ 0.19805527 -0.62915986  0.00924648  0.02618232  1.02491764]
  </code></pre>
  
  <p>In this case, How does the error quantify the quality of the intrinsic parameters estimation?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>So i went looking for answers and digging a bit deeper and checking the cpp implementation of this function.</p>
  
  <p>This is the function computing this error value :</p>
  
  <pre><code>static double computeReprojectionErrors(
          const vector&lt;vector&lt;Point3f&gt; &gt;&amp; objectPoints,
          const vector&lt;vector&lt;Point2f&gt; &gt;&amp; imagePoints,
          const vector&lt;Mat&gt;&amp; rvecs, const vector&lt;Mat&gt;&amp; tvecs,
          const Mat&amp; cameraMatrix, const Mat&amp; distCoeffs,
          vector&lt;float&gt;&amp; perViewErrors )
  {
      vector&lt;Point2f&gt; imagePoints2;
      int i, totalPoints = 0;
      double totalErr = 0, err;
      perViewErrors.resize(objectPoints.size());
  
      for( i = 0; i &lt; (int)objectPoints.size(); i++ )
      {
          projectPoints(Mat(objectPoints[i]), rvecs[i], tvecs[i],
                        cameraMatrix, distCoeffs, imagePoints2);
          err = norm(Mat(imagePoints[i]), Mat(imagePoints2), NORM_L2);
          int n = (int)objectPoints[i].size();
          perViewErrors[i] = (float)std::sqrt(err*err/n);
          totalErr += err*err;
          totalPoints += n;
      }
  
      return std::sqrt(totalErr/totalPoints);
  }
  </code></pre>
  
  <p>This error is computed considering the tvecs and rvecs found with cv2.CalibrateCamera, it reproject the points used for finding those translation and rotation vectors and computes the euclidian distance between the reprojected point and the actual coordinates of those points.</p>
  
  <p>I don't think this error is bounded in [0,1] but is instead depending on the range of the coordinates used for the calibration. So it's depending on the resolution of the images used for the calibration. </p>
  
  <p>Can someone confirm/refute this?</p>