Subversion Repositories seema-scanner

Rev

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

Rev 81 Rev 84
Line 113... Line 113...
113
    cal.R1 = R1;
113
    cal.R1 = R1;
114
    cal.T1 = T1;
114
    cal.T1 = T1;
115
    cal.E = E;
115
    cal.E = E;
116
    cal.F = F;
116
    cal.F = F;
117
 
117
 
118
    // calibrate rotation axis
118
    // calibrate rotation axis 1
119
    std::vector<cv::Matx33f> Rc(nValidSets - 1); // rotations/translations of the checkerboard in camera 0 reference frame
119
    std::vector<cv::Matx33f> Rc(nValidSets - 1); // rotations/translations of the checkerboard in camera 0 reference frame
120
    std::vector<cv::Vec3f> Tc(nValidSets - 1);
120
    std::vector<cv::Vec3f> Tc(nValidSets - 1);
121
    std::vector<cv::Matx33f> Rr(nValidSets - 1); // in rotation stage reference frame
121
    std::vector<cv::Matx33f> Rr(nValidSets - 1); // in rotation stage reference frame
122
    std::vector<cv::Vec3f> Tr(nValidSets - 1);
122
    std::vector<cv::Vec3f> Tr(nValidSets - 1);
123
    for(int i=0; i<nValidSets-1; i++){
123
    for(int i=0; i<nValidSets-1; i++){
Line 182... Line 182...
182
        std::cout << "Rcr[i]" << Rcr << std::endl;
182
        std::cout << "Rcr[i]" << Rcr << std::endl;
183
        std::cout << "Tcr[i]" << Tcr << std::endl;
183
        std::cout << "Tcr[i]" << Tcr << std::endl;
184
        std::cout << std::endl;
184
        std::cout << std::endl;
185
    }
185
    }
186
 
186
 
-
 
187
    //* Using rotation axis calibration *//
-
 
188
    // full camera matrices
-
 
189
    cv::Matx34f P0 = cal.K0*cv::Matx34f::eye();
-
 
190
    cv::Mat RT1(3, 4, CV_32F);
-
 
191
    cv::Mat(cal.R1).copyTo(RT1(cv::Range(0, 3), cv::Range(0, 3)));
-
 
192
    cv::Mat(cal.T1).copyTo(RT1(cv::Range(0, 3), cv::Range(3, 4)));
-
 
193
    cv::Matx34f P1 = cal.K1*cv::Matx34f(RT1);
-
 
194
 
-
 
195
    // calibration points in camera 0 frame
-
 
196
    std::vector< std::vector<cv::Point3f> > Qcam;
-
 
197
 
-
 
198
    for(int i=0; i<nValidSets; i++){
-
 
199
        std::vector<cv::Point3f> qc0i, qc1i;
-
 
200
        cv::undistortPoints(qc0[i], qc0i, cal.K0, cal.k0);
-
 
201
        cv::undistortPoints(qc1[i], qc1i, cal.K0, cal.k0);
-
 
202
 
187
    cv::Mat rrvec;
203
        cv::Mat Qhom, Qcami;
-
 
204
        cv::triangulatePoints(P0, P1, qc0i, qc1i, Qhom);
-
 
205
        cvtools::convertMatFromHomogeneous(Qhom, Qcami);
-
 
206
        std::vector<cv::Point3f> QcamiPoints;
-
 
207
        cvtools::matToPoints3f(Qcami, QcamiPoints);
-
 
208
 
-
 
209
        Qcam.push_back(QcamiPoints);
-
 
210
    }
-
 
211
 
188
    cv::Rodrigues(cal.Rr, rrvec);
212
    cv::Vec3f axis, point;
-
 
213
    cvtools::rotationAxisCalibration(Qcam, Qi, axis, point);
-
 
214
 
-
 
215
    // construct transformation matrix
189
    std::cout << "rrvec:" << rrvec << std::endl;
216
    cv::Vec3f ex = axis.cross(cv::Vec3f(0,0,1.0));
-
 
217
    cv::Vec3f ez = axis.cross(ex);
-
 
218
 
-
 
219
    cal.Rr.col(0) = ex;
-
 
220
    cal.Rr.col(1) = axis;
-
 
221
    cal.Rr.col(2) = ez;
-
 
222
 
-
 
223
    cal.Tr = point;
190
 
224
 
191
    // Print to std::cout
225
    // Print to std::cout
192
    cal.print();
226
    cal.print();
193
 
227
 
194
    // save to (reentrant qsettings object)
228
    // save to (reentrant qsettings object)