MCPcopy Create free account
hub / github.com/cpvrlab/ImagePlay / computeReprojectionErrors

Method computeReprojectionErrors

IPL/src/processes/IPLCameraCalibration.cpp:241–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239}
240
241double IPLCameraCalibration::computeReprojectionErrors(
242 const std::vector<std::vector<cv::Point3f> >& objectPoints,
243 const std::vector<std::vector<cv::Point2f> >& imagePoints,
244 const std::vector<cv::Mat>& rvecs, const std::vector<cv::Mat>& tvecs,
245 const cv::Mat& cameraMatrix, const cv::Mat& distCoeffs,
246 std::vector<float>& perViewErrors )
247{
248 std::vector<cv::Point2f> imagePoints2;
249 int i, totalPoints = 0;
250 double totalErr = 0, err;
251 perViewErrors.resize(objectPoints.size());
252
253 for( i = 0; i < (int)objectPoints.size(); i++ )
254 {
255 projectPoints(cv::Mat(objectPoints[i]), rvecs[i], tvecs[i],
256 cameraMatrix, distCoeffs, imagePoints2);
257 err = cv::norm(cv::Mat(imagePoints[i]), cv::Mat(imagePoints2), cv::NORM_L2);
258 int n = (int)objectPoints[i].size();
259 perViewErrors[i] = (float)std::sqrt(err*err/n);
260 totalErr += err*err;
261 totalPoints += n;
262 }
263
264 return std::sqrt(totalErr/totalPoints);
265}
266/*
267static void IPLCameraCalibration::saveCameraParams( const string& filename,
268 Size imageSize, Size boardSize,

Callers 1

runCalibrationMethod · 0.95

Calls 4

MatFunction · 0.85
normFunction · 0.50
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected