@@ -345,7 +345,7 @@ TEST_F(fisheyeTest, Calibration)
345
345
std::vector<std::vector<cv::Point2d> > imagePoints (n_images);
346
346
std::vector<std::vector<cv::Point3d> > objectPoints (n_images);
347
347
348
- const std::string folder =combine (datasets_repository_path, " calib-3_stereo_from_JY" );
348
+ const std::string folder = combine (datasets_repository_path, " calib-3_stereo_from_JY" );
349
349
cv::FileStorage fs_left (combine (folder, " left.xml" ), cv::FileStorage::READ);
350
350
CV_Assert (fs_left.isOpened ());
351
351
for (int i = 0 ; i < n_images; ++i)
@@ -373,14 +373,61 @@ TEST_F(fisheyeTest, Calibration)
373
373
EXPECT_MAT_NEAR (theD, this ->D , 1e-10 );
374
374
}
375
375
376
+ TEST_F (fisheyeTest, CalibrationWithFixedFocalLength)
377
+ {
378
+ const int n_images = 34 ;
379
+
380
+ std::vector<std::vector<cv::Point2d> > imagePoints (n_images);
381
+ std::vector<std::vector<cv::Point3d> > objectPoints (n_images);
382
+
383
+ const std::string folder =combine (datasets_repository_path, " calib-3_stereo_from_JY" );
384
+ cv::FileStorage fs_left (combine (folder, " left.xml" ), cv::FileStorage::READ);
385
+ CV_Assert (fs_left.isOpened ());
386
+ for (int i = 0 ; i < n_images; ++i)
387
+ fs_left[cv::format (" image_%d" , i )] >> imagePoints[i];
388
+ fs_left.release ();
389
+
390
+ cv::FileStorage fs_object (combine (folder, " object.xml" ), cv::FileStorage::READ);
391
+ CV_Assert (fs_object.isOpened ());
392
+ for (int i = 0 ; i < n_images; ++i)
393
+ fs_object[cv::format (" image_%d" , i )] >> objectPoints[i];
394
+ fs_object.release ();
395
+
396
+ int flag = 0 ;
397
+ flag |= cv::fisheye::CALIB_RECOMPUTE_EXTRINSIC;
398
+ flag |= cv::fisheye::CALIB_CHECK_COND;
399
+ flag |= cv::fisheye::CALIB_FIX_SKEW;
400
+ flag |= cv::fisheye::CALIB_FIX_FOCAL_LENGTH;
401
+ flag |= cv::fisheye::CALIB_USE_INTRINSIC_GUESS;
402
+
403
+ cv::Matx33d theK = this ->K ;
404
+ const cv::Matx33d newK (
405
+ 558.478088 , 0.000000 , 620.458461 ,
406
+ 0.000000 , 560.506767 , 381.939362 ,
407
+ 0.000000 , 0.000000 , 1.000000 );
408
+
409
+ cv::Vec4d theD;
410
+ const cv::Vec4d newD (-0.001461 , -0.003298 , 0.006057 , -0.003742 );
411
+
412
+ cv::fisheye::calibrate (objectPoints, imagePoints, imageSize, theK, theD,
413
+ cv::noArray (), cv::noArray (), flag, cv::TermCriteria (3 , 20 , 1e-6 ));
414
+
415
+ // ensure that CALIB_FIX_FOCAL_LENGTH works and focal lenght has not changed
416
+ EXPECT_EQ (theK (0 ,0 ), K (0 ,0 ));
417
+ EXPECT_EQ (theK (1 ,1 ), K (1 ,1 ));
418
+
419
+ EXPECT_MAT_NEAR (theK, newK, 1e-6 );
420
+ EXPECT_MAT_NEAR (theD, newD, 1e-6 );
421
+ }
422
+
376
423
TEST_F (fisheyeTest, Homography)
377
424
{
378
425
const int n_images = 1 ;
379
426
380
427
std::vector<std::vector<cv::Point2d> > imagePoints (n_images);
381
428
std::vector<std::vector<cv::Point3d> > objectPoints (n_images);
382
429
383
- const std::string folder =combine (datasets_repository_path, " calib-3_stereo_from_JY" );
430
+ const std::string folder = combine (datasets_repository_path, " calib-3_stereo_from_JY" );
384
431
cv::FileStorage fs_left (combine (folder, " left.xml" ), cv::FileStorage::READ);
385
432
CV_Assert (fs_left.isOpened ());
386
433
for (int i = 0 ; i < n_images; ++i)
@@ -498,7 +545,7 @@ TEST_F(fisheyeTest, stereoRectify)
498
545
" For the purpose of continuity the following should be true: cv::CALIB_ZERO_DISPARITY == cv::fisheye::CALIB_ZERO_DISPARITY"
499
546
);
500
547
501
- const std::string folder =combine (datasets_repository_path, " calib-3_stereo_from_JY" );
548
+ const std::string folder = combine (datasets_repository_path, " calib-3_stereo_from_JY" );
502
549
503
550
cv::Size calibration_size = this ->imageSize , requested_size = calibration_size;
504
551
cv::Matx33d K1 = this ->K , K2 = K1;
@@ -599,7 +646,7 @@ TEST_F(fisheyeTest, stereoCalibrate)
599
646
{
600
647
const int n_images = 34 ;
601
648
602
- const std::string folder =combine (datasets_repository_path, " calib-3_stereo_from_JY" );
649
+ const std::string folder = combine (datasets_repository_path, " calib-3_stereo_from_JY" );
603
650
604
651
std::vector<std::vector<cv::Point2d> > leftPoints (n_images);
605
652
std::vector<std::vector<cv::Point2d> > rightPoints (n_images);
@@ -666,7 +713,7 @@ TEST_F(fisheyeTest, stereoCalibrateFixIntrinsic)
666
713
{
667
714
const int n_images = 34 ;
668
715
669
- const std::string folder =combine (datasets_repository_path, " calib-3_stereo_from_JY" );
716
+ const std::string folder = combine (datasets_repository_path, " calib-3_stereo_from_JY" );
670
717
671
718
std::vector<std::vector<cv::Point2d> > leftPoints (n_images);
672
719
std::vector<std::vector<cv::Point2d> > rightPoints (n_images);
@@ -822,6 +869,7 @@ const cv::Matx33d fisheyeTest::K(558.478087865323, 0, 620.45851536
822
869
823
870
const cv::Vec4d fisheyeTest::D (-0.0014613319981768 , -0.00329861110580401 , 0.00605760088590183 , -0.00374209380722371 );
824
871
872
+
825
873
const cv::Matx33d fisheyeTest::R ( 9.9756700084424932e-01 , 6.9698277640183867e-02 , 1.4929569991321144e-03 ,
826
874
-6.9711825162322980e-02 , 9.9748249845531767e-01 , 1.2997180766418455e-02 ,
827
875
-5.8331736398316541e-04 ,-1.3069635393884985e-02 , 9.9991441852366736e-01 );
0 commit comments