From: Ilya Lysenkov Date: Thu, 29 Mar 2012 10:39:48 +0000 (+0000) Subject: Added a test for the C++ wrapper of cvTriangulatePoints() X-Git-Tag: accepted/2.0/20130307.220821~930 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7901879e48e8235b52a7d3239ba2e965ad01e212;p=profile%2Fivi%2Fopencv.git Added a test for the C++ wrapper of cvTriangulatePoints() --- diff --git a/modules/calib3d/test/test_cameracalibration.cpp b/modules/calib3d/test/test_cameracalibration.cpp index 31da445..3db84b0 100644 --- a/modules/calib3d/test/test_cameracalibration.cpp +++ b/modules/calib3d/test/test_cameracalibration.cpp @@ -1282,6 +1282,9 @@ protected: virtual bool rectifyUncalibrated( const Mat& points1, const Mat& points2, const Mat& F, Size imgSize, Mat& H1, Mat& H2, double threshold=5 ) = 0; + virtual void triangulate( const Mat& P1, const Mat& P2, + const Mat &points1, const Mat &points2, + Mat &points4D ) = 0; void run(int); }; @@ -1515,15 +1518,10 @@ void CV_StereoCalibrationTest::run( int ) Mat ys_2 = projectedPoints_2.row(1); projectedPoints_1.row(1).copyTo(ys_2); - const int dimension = 4; - Mat points4d(dimension, pointsCount, CV_32FC1); - CvMat cvPoints4d = points4d; - CvMat cvP1 = P1; - CvMat cvP2 = P2; - CvMat cvPoints1 = projectedPoints_1; - CvMat cvPoints2 = projectedPoints_2; - cvTriangulatePoints(&cvP1, &cvP2, &cvPoints1, &cvPoints2, &cvPoints4d); + Mat points4d; + triangulate(P1, P2, projectedPoints_1, projectedPoints_2, points4d); Mat homogeneousPoints4d = points4d.t(); + const int dimension = 4; homogeneousPoints4d = homogeneousPoints4d.reshape(dimension); Mat triangulatedPoints; convertPointsFromHomogeneous(homogeneousPoints4d, triangulatedPoints); @@ -1635,6 +1633,9 @@ protected: virtual bool rectifyUncalibrated( const Mat& points1, const Mat& points2, const Mat& F, Size imgSize, Mat& H1, Mat& H2, double threshold=5 ); + virtual void triangulate( const Mat& P1, const Mat& P2, + const Mat &points1, const Mat &points2, + Mat &points4D ); }; double CV_StereoCalibrationTest_C::calibrateStereoCamera( const vector >& objectPoints, @@ -1718,6 +1719,15 @@ bool CV_StereoCalibrationTest_C::rectifyUncalibrated( const Mat& points1, return cvStereoRectifyUncalibrated(&_pt1, &_pt2, pF, imgSize, &_H1, &_H2, threshold) > 0; } +void CV_StereoCalibrationTest_C::triangulate( const Mat& P1, const Mat& P2, + const Mat &points1, const Mat &points2, + Mat &points4D ) +{ + CvMat _P1 = P1, _P2 = P2, _points1 = points1, _points2 = points2; + points4D.create(4, points1.cols, points1.type()); + CvMat _points4D = points4D; + cvTriangulatePoints(&_P1, &_P2, &_points1, &_points2, &_points4D); +} //-------------------------------- CV_StereoCalibrationTest_CPP ------------------------------ @@ -1742,6 +1752,9 @@ protected: virtual bool rectifyUncalibrated( const Mat& points1, const Mat& points2, const Mat& F, Size imgSize, Mat& H1, Mat& H2, double threshold=5 ); + virtual void triangulate( const Mat& P1, const Mat& P2, + const Mat &points1, const Mat &points2, + Mat &points4D ); }; double CV_StereoCalibrationTest_CPP::calibrateStereoCamera( const vector >& objectPoints, @@ -1774,6 +1787,13 @@ bool CV_StereoCalibrationTest_CPP::rectifyUncalibrated( const Mat& points1, return stereoRectifyUncalibrated( points1, points2, F, imgSize, H1, H2, threshold ); } +void CV_StereoCalibrationTest_CPP::triangulate( const Mat& P1, const Mat& P2, + const Mat &points1, const Mat &points2, + Mat &points4D ) +{ + triangulatePoints(P1, P2, points1, points2, points4D); +} + /////////////////////////////////////////////////////////////////////////////////////////////////// TEST(Calib3d_CalibrateCamera_C, regression) { CV_CameraCalibrationTest_C test; test.safe_run(); }