From d9001d1a91065c2ee21beb0cac3de4b0a739ace8 Mon Sep 17 00:00:00 2001 From: Ilya Lysenkov Date: Tue, 27 Mar 2012 15:01:26 +0000 Subject: [PATCH] Added a check that Q (computed by rectification) reprojects a point before the camera --- modules/calib3d/test/test_cameracalibration.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/calib3d/test/test_cameracalibration.cpp b/modules/calib3d/test/test_cameracalibration.cpp index 1e3eda5..c98f372 100644 --- a/modules/calib3d/test/test_cameracalibration.cpp +++ b/modules/calib3d/test/test_cameracalibration.cpp @@ -1478,6 +1478,16 @@ void CV_StereoCalibrationTest::run( int ) return; } + //check that Q reprojects points before the camera + double testPoint[4] = {0.0, 0.0, 100.0, 1.0}; + Mat reprojectedTestPoint = Q * Mat_(4, 1, testPoint); + CV_Assert(reprojectedTestPoint.type() == CV_64FC1); + if( reprojectedTestPoint.at(2) / reprojectedTestPoint.at(3) < 0 ) + { + ts->printf( cvtest::TS::LOG, "A point after rectification is reprojected behind the camera, testcase %d\n", testcase); + ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT ); + } + // rectifyUncalibrated CV_Assert( imgpt1.size() == imgpt2.size() ); Mat _imgpt1( total, 1, CV_32FC2 ), _imgpt2( total, 1, CV_32FC2 ); -- 2.7.4