Line 1... |
Line 1... |
1 |
#include "SMCalibrator.h"
|
1 |
#include "SMCalibrator.h"
|
2 |
|
2 |
|
3 |
#include <QSettings>
|
3 |
#include <QSettings>
|
4 |
|
4 |
|
5 |
void SMCalibrator::performCalibration(std::vector< CalibrationSet > calibrationData){
|
5 |
void SMCalibrator::performCalibration(std::vector<CalibrationSet> &calibrationData){
|
6 |
|
6 |
|
7 |
// Number of saddle points on calibration pattern
|
7 |
// Number of saddle points on calibration pattern
|
8 |
cv::Size patternSize(10, 9);
|
8 |
cv::Size patternSize(10, 9);
|
9 |
|
9 |
|
10 |
int nSets = calibrationData.size();
|
10 |
int nSets = calibrationData.size();
|
Line 22... |
Line 22... |
22 |
// Camera 0
|
22 |
// Camera 0
|
23 |
std::vector<cv::Point2f> qci0;
|
23 |
std::vector<cv::Point2f> qci0;
|
24 |
// Extract checker corners
|
24 |
// Extract checker corners
|
25 |
bool success0 = cv::findChessboardCorners(calibrationSetI.frame0, patternSize, qci0, cv::CALIB_CB_ADAPTIVE_THRESH);
|
25 |
bool success0 = cv::findChessboardCorners(calibrationSetI.frame0, patternSize, qci0, cv::CALIB_CB_ADAPTIVE_THRESH);
|
26 |
if(success0){
|
26 |
if(success0){
|
- |
|
27 |
cv::Mat gray;
|
- |
|
28 |
cv::cvtColor(calibrationSetI.frame0, gray, CV_RGB2GRAY);
|
27 |
cv::cornerSubPix(calibrationSetI.frame0, qci0, cv::Size(5, 5), cv::Size(-1, -1),cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 100, 0.001));
|
29 |
cv::cornerSubPix(gray, qci0, cv::Size(5, 5), cv::Size(-1, -1),cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 100, 0.001));
|
28 |
// Draw colored chessboard
|
30 |
// Draw colored chessboard
|
29 |
cv::cvtColor(calibrationSetI.frame0, calibrationSetI.frame0Result, CV_GRAY2RGB);
|
31 |
calibrationSetI.frame0Result = calibrationSetI.frame0.clone();
|
30 |
cv::drawChessboardCorners(calibrationSetI.frame0Result, patternSize, qci0, success0);
|
32 |
cv::drawChessboardCorners(calibrationSetI.frame0Result, patternSize, qci0, success0);
|
31 |
}
|
33 |
}
|
32 |
|
34 |
|
33 |
// Camera 1
|
35 |
// Camera 1
|
34 |
std::vector<cv::Point2f> qci1;
|
36 |
std::vector<cv::Point2f> qci1;
|
35 |
// Extract checker corners
|
37 |
// Extract checker corners
|
36 |
bool success1 = cv::findChessboardCorners(calibrationSetI.frame1, patternSize, qci1, cv::CALIB_CB_ADAPTIVE_THRESH);
|
38 |
bool success1 = cv::findChessboardCorners(calibrationSetI.frame1, patternSize, qci1, cv::CALIB_CB_ADAPTIVE_THRESH);
|
37 |
if(success1){
|
39 |
if(success1){
|
- |
|
40 |
cv::Mat gray;
|
- |
|
41 |
cv::cvtColor(calibrationSetI.frame1, gray, CV_RGB2GRAY);
|
38 |
cv::cornerSubPix(calibrationSetI.frame1, qci1, cv::Size(5, 5), cv::Size(-1, -1),cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 100, 0.001));
|
42 |
cv::cornerSubPix(gray, qci1, cv::Size(5, 5), cv::Size(-1, -1),cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 100, 0.001));
|
39 |
// Draw colored chessboard
|
43 |
// Draw colored chessboard
|
40 |
cv::cvtColor(calibrationSetI.frame1, calibrationSetI.frame1Result, CV_GRAY2RGB);
|
44 |
calibrationSetI.frame1Result = calibrationSetI.frame1.clone();
|
41 |
cv::drawChessboardCorners(calibrationSetI.frame1Result, patternSize, qci1, success1);
|
45 |
cv::drawChessboardCorners(calibrationSetI.frame1Result, patternSize, qci1, success1);
|
42 |
}
|
46 |
}
|
43 |
|
47 |
|
44 |
calibrationSetI.success = success0 && success1;
|
48 |
calibrationSetI.success = success0 && success1;
|
45 |
|
49 |
|