make cv::calibrateCamera, cv::stereoCalibrate and their C counterparts return the standard RMS error.
This commit is contained in:
parent
8754cafffb
commit
3fd07809c9
@ -1742,7 +1742,7 @@ CV_IMPL double cvCalibrateCamera2( const CvMat* objectPoints,
|
||||
}
|
||||
}
|
||||
|
||||
return reprojErr;
|
||||
return std::sqrt(reprojErr/total);
|
||||
}
|
||||
|
||||
|
||||
@ -2254,7 +2254,7 @@ double cvStereoCalibrate( const CvMat* _objectPoints, const CvMat* _imagePoints1
|
||||
}
|
||||
}
|
||||
|
||||
return reprojErr;
|
||||
return std::sqrt(reprojErr/(pointsTotal*2));
|
||||
}
|
||||
|
||||
|
||||
|
@ -91,14 +91,14 @@ static double computeReprojectionErrors(
|
||||
{
|
||||
projectPoints(Mat(objectPoints[i]), rvecs[i], tvecs[i],
|
||||
cameraMatrix, distCoeffs, imagePoints2);
|
||||
err = norm(Mat(imagePoints[i]), Mat(imagePoints2), CV_L1 );
|
||||
err = norm(Mat(imagePoints[i]), Mat(imagePoints2), CV_L2);
|
||||
int n = (int)objectPoints[i].size();
|
||||
perViewErrors[i] = (float)(err/n);
|
||||
totalErr += err;
|
||||
perViewErrors[i] = (float)std::sqrt(err*err/n);
|
||||
totalErr += err*err;
|
||||
totalPoints += n;
|
||||
}
|
||||
|
||||
return totalErr/totalPoints;
|
||||
return std::sqrt(totalErr/totalPoints);
|
||||
}
|
||||
|
||||
static void calcChessboardCorners(Size boardSize, float squareSize, vector<Point3f>& corners)
|
||||
@ -130,9 +130,10 @@ static bool runCalibration( vector<vector<Point2f> > imagePoints,
|
||||
|
||||
objectPoints.resize(imagePoints.size(),objectPoints[0]);
|
||||
|
||||
calibrateCamera(objectPoints, imagePoints, imageSize, cameraMatrix,
|
||||
double rms = calibrateCamera(objectPoints, imagePoints, imageSize, cameraMatrix,
|
||||
distCoeffs, rvecs, tvecs, flags|CV_CALIB_FIX_K4|CV_CALIB_FIX_K5);
|
||||
///*|CV_CALIB_FIX_K3*/|CV_CALIB_FIX_K4|CV_CALIB_FIX_K5);
|
||||
printf("RMS error reported by calibrateCamera: %g\n", rms);
|
||||
|
||||
bool ok = checkRange(cameraMatrix) && checkRange(distCoeffs);
|
||||
|
||||
|
@ -162,7 +162,7 @@ StereoCalib(const vector<string>& imagelist, Size boardSize, bool useCalibrated=
|
||||
cameraMatrix[1] = Mat::eye(3, 3, CV_64F);
|
||||
Mat R, T, E, F;
|
||||
|
||||
stereoCalibrate(objectPoints, imagePoints[0], imagePoints[1],
|
||||
double rms = stereoCalibrate(objectPoints, imagePoints[0], imagePoints[1],
|
||||
cameraMatrix[0], distCoeffs[0],
|
||||
cameraMatrix[1], distCoeffs[1],
|
||||
imageSize, R, T, E, F,
|
||||
@ -170,7 +170,7 @@ StereoCalib(const vector<string>& imagelist, Size boardSize, bool useCalibrated=
|
||||
CV_CALIB_FIX_ASPECT_RATIO +
|
||||
CV_CALIB_ZERO_TANGENT_DIST +
|
||||
CV_CALIB_SAME_FOCAL_LENGTH);
|
||||
cout << "done\n";
|
||||
cout << "done with RMS error=" << rms << endl;
|
||||
|
||||
// CALIBRATION QUALITY CHECK
|
||||
// because the output fundamental matrix implicitly
|
||||
|
Loading…
x
Reference in New Issue
Block a user