Subversion Repositories seema-scanner

Rev

Rev 198 | Rev 207 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 198 Rev 206
Line 54... Line 54...
54
 
54
 
55
 
55
 
56
// Closed form solution to solve for the rotation axis from sets of 3D point coordinates of flat pattern feature points
56
// Closed form solution to solve for the rotation axis from sets of 3D point coordinates of flat pattern feature points
57
// Algorithm according to Chen et al., Rotation axis calibration of a turntable using constrained global optimization, Optik 2014
57
// Algorithm according to Chen et al., Rotation axis calibration of a turntable using constrained global optimization, Optik 2014
58
// DTU, 2014, Jakob Wilm
58
// DTU, 2014, Jakob Wilm
59
static void rotationAxisCalibration(const std::vector< std::vector<cv::Point3f> > Qcam, const std::vector<cv::Point3f> Qobj, cv::Vec3f &axis, cv::Vec3f &point, float &error){
59
static void rotationAxisCalibration(const std::vector< std::vector<cv::Point3f> > Qcam,
-
 
60
                                    const std::vector<cv::Point3f> Qobj,
-
 
61
                                    cv::Vec3f &axis, cv::Vec3f &point, float &error){
60
 
62
 
61
    // number of frames (points on each arch)
63
    // number of frames (points on each arch)
62
    int l = Qcam.size();
64
    int l = Qcam.size();
63
 
65
 
64
    // number of points in each frame
66
    // number of points in each frame
Line 242... Line 244...
242
        error += meanDev;
244
        error += meanDev;
243
    }
245
    }
244
    error /= mn;
246
    error /= mn;
245
}
247
}
246
 
248
 
-
 
249
bool processCBCorners(const cv::Size & checkerCount,
-
 
250
                      const cv::Mat & SMCalibrationSetI_frameX,
-
 
251
                      cv::Mat & SMCalibrationSetI_frameXResult,
-
 
252
                      std::vector<cv::Point2f> & qciX){
-
 
253
    // Convert to grayscale
-
 
254
    cv::Mat gray;
-
 
255
    if(SMCalibrationSetI_frameX.channels() == 1)
-
 
256
        cv::cvtColor(SMCalibrationSetI_frameX, gray, CV_BayerBG2GRAY);
-
 
257
    else
-
 
258
        cv::cvtColor(SMCalibrationSetI_frameX, gray, CV_RGB2GRAY);
-
 
259
 
-
 
260
    // Extract checker corners
-
 
261
    bool success = cv::findChessboardCorners(gray, checkerCount, qciX, cv::CALIB_CB_ADAPTIVE_THRESH + cv::CALIB_CB_FAST_CHECK);
-
 
262
    if(success){
-
 
263
        cv::cornerSubPix(gray, qciX, cv::Size(6, 6), cv::Size(1, 1), cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 20, 0.0001));
-
 
264
        // Draw colored chessboard
-
 
265
        cv::Mat color;
-
 
266
        if(SMCalibrationSetI_frameX.channels() == 1)
-
 
267
            cv::cvtColor(SMCalibrationSetI_frameX, color, CV_BayerBG2RGB);
-
 
268
        else
-
 
269
            color = SMCalibrationSetI_frameX.clone();
-
 
270
 
-
 
271
        cvtools::drawChessboardCorners(color, checkerCount, qciX, success, 10);
-
 
272
        SMCalibrationSetI_frameXResult = color;
-
 
273
    }
-
 
274
    return success;
-
 
275
}
-
 
276
 
247
void SMCalibrationWorker::performCalibration(std::vector<SMCalibrationSet> calibrationData){
277
void SMCalibrationWorker::performCalibration(std::vector<SMCalibrationSet> calibrationData){
248
 
278
 
249
    QSettings settings;
279
    QSettings settings;
250
 
280
 
251
    // Number of saddle points on calibration pattern
281
    // Number of saddle points on calibration pattern
Line 385... Line 415...
385
//std::cout << cal.k1 << std::endl;
415
//std::cout << cal.k1 << std::endl;
386
    // stereo calibration
416
    // stereo calibration
387
    int flags_stereo = cv::CALIB_FIX_INTRINSIC;// + cv::CALIB_FIX_K2 + cv::CALIB_FIX_K3 + cv::CALIB_ZERO_TANGENT_DIST + cv::CALIB_FIX_PRINCIPAL_POINT + cv::CALIB_FIX_ASPECT_RATIO;
417
    int flags_stereo = cv::CALIB_FIX_INTRINSIC;// + cv::CALIB_FIX_K2 + cv::CALIB_FIX_K3 + cv::CALIB_ZERO_TANGENT_DIST + cv::CALIB_FIX_PRINCIPAL_POINT + cv::CALIB_FIX_ASPECT_RATIO;
388
    cv::Mat E, F, R1, T1;
418
    cv::Mat E, F, R1, T1;
389
    cal.stereo_error = cv::stereoCalibrate(QStereo, qc0Stereo, qc1Stereo, cal.K0, cal.k0, cal.K1, cal.k1,
419
    cal.stereo_error = cv::stereoCalibrate(QStereo, qc0Stereo, qc1Stereo, cal.K0, cal.k0, cal.K1, cal.k1,
390
                                              frameSize, R1, T1, E, F,
420
                                              frameSize, R1, T1, E, F, flags_stereo,
391
                                              cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, 200, DBL_EPSILON),
421
                                              cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, 200, DBL_EPSILON));
392
                                              flags_stereo);
-
 
393
 
422
 
394
    cal.R1 = R1;
423
    cal.R1 = R1;
395
    cal.T1 = T1;
424
    cal.T1 = T1;
396
    cal.E = E;
425
    cal.E = E;
397
    cal.F = F;
426
    cal.F = F;