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

Method runCalibration

IPL/src/processes/IPLCameraCalibration.cpp:189–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187}
188
189bool IPLCameraCalibration::runCalibration(std::vector<std::vector<cv::Point2f> > imagePoints,
190 cv::Size imageSize, cv::Size boardSize, Pattern patternType,
191 float squareSize, float aspectRatio,
192 int flags, cv::Mat& cameraMatrix, cv::Mat& distCoeffs,
193 std::vector<cv::Mat>& rvecs, std::vector<cv::Mat>& tvecs,
194 std::vector<float>& reprojErrs,
195 double& totalAvgErr)
196{
197 cameraMatrix = cv::Mat::eye(3, 3, CV_64F);
198 if( flags & cv::CALIB_FIX_ASPECT_RATIO )
199 cameraMatrix.at<double>(0,0) = aspectRatio;
200
201 distCoeffs = cv::Mat::zeros(8, 1, CV_64F);
202
203 std::vector<std::vector<cv::Point3f> > objectPoints(1);
204 this->calcChessboardCorners(boardSize, squareSize, objectPoints[0], patternType);
205
206 objectPoints.resize(imagePoints.size(),objectPoints[0]);
207
208 double rms = calibrateCamera(objectPoints, imagePoints, imageSize, cameraMatrix,
209 distCoeffs, rvecs, tvecs, flags|cv::CALIB_FIX_K4|cv::CALIB_FIX_K5);
210 ///*|CALIB_FIX_K3*/|CALIB_FIX_K4|CALIB_FIX_K5);
211
212 bool ok = checkRange(cameraMatrix) && checkRange(distCoeffs);
213
214 totalAvgErr = this->computeReprojectionErrors(objectPoints, imagePoints,
215 rvecs, tvecs, cameraMatrix, distCoeffs, reprojErrs);
216
217 return ok;
218}
219
220void IPLCameraCalibration::calcChessboardCorners(cv::Size boardSize, float squareSize, std::vector<cv::Point3f>& corners, Pattern patternType)
221{

Callers 1

processInputDataMethod · 0.95

Calls 4

calcChessboardCornersMethod · 0.95
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected