Retval return value in cv2.CalibrateCamera

as the name says, my question is about the return value given by the calibrateCamera function from OpenCv.

http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html

I have a functional implementation in python to find the internal parameters and distortion coefficients for a camera using the Black & White grid.

The question is more about the return function retval. If I understand correctly, this is the "average re-projection error", which gives a good estimate of the accuracy of the parameters found, which should be as close to zero as possible. "

http://docs.opencv.org/doc/tutorials/calib3d/camera_calibration/camera_calibration.html

What exactly means a value close to zero, how is this possible?

For example, when I do this for my Logitech webcam:

RMS: 0.702660793513

camera matrix:

 [[ 616.30868126 0. 339.02126978] [ 0. 605.08224927 241.64607568] [ 0. 0. 1. ]] 

Distortion factors:

 [ 0.19805527 -0.62915986 0.00924648 0.02618232 1.02491764] 

In this case, how does the error quantify the quality of the evaluation of its own parameters?

EDIT:

So, I went looking for answers and dug a little deeper and checked the implementation of this cpp function.

This is the function that calculates this error value:

 static double computeReprojectionErrors( const vector<vector<Point3f> >& objectPoints, const vector<vector<Point2f> >& imagePoints, const vector<Mat>& rvecs, const vector<Mat>& tvecs, const Mat& cameraMatrix, const Mat& distCoeffs, vector<float>& perViewErrors ) { vector<Point2f> imagePoints2; int i, totalPoints = 0; double totalErr = 0, err; perViewErrors.resize(objectPoints.size()); for( i = 0; i < (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); } 

This error is calculated taking into account the tvecs and rvecs found using cv2.CalibrateCamera, it reprograms the points used to find these translation and rotation vectors, and calculates the Euclidean distance between the reprogrammed point and the actual coordinates of these points.

I do not think that this error is limited in [0,1], but instead depends on the range of coordinates used for calibration. Thus, it depends on the resolution of the images used for calibration.

Can someone confirm / refute this?

+5
source share
1 answer

calibrateCamera returns a mean square re-projection error (RMS), usually it should be between 0.1 and 1.0 pixels in a good calibration.
The calculation is performed by projecting the points of a 3D checkerboard ( objectPoints ) objectPoints the image plane using the final set of calibration parameters ( cameraMatrix , distCoeffs , rvecs and tvecs ) and comparing the known position of the corners ( imagePoints ).

A RMS 1.0 error means that on average each of these projected points is 1.0 px from its actual position. The error is not limited in [0, 1], it can be considered as a distance.

+6
source

All Articles