}\r
~CV_ReprojectImageTo3DTest() {}\r
protected: \r
+\r
\r
void run(int)\r
- {\r
+ { \r
ts->set_failed_test_info(CvTS::OK);\r
+ int progress = 0;\r
\r
+ progress = update_progress( progress, 1, 14, 0 );\r
runCase<float, float>(-100.f, 100.f);\r
+ progress = update_progress( progress, 2, 14, 0 );\r
runCase<int, float>(-100, 100);\r
+ progress = update_progress( progress, 3, 14, 0 );\r
runCase<short, float>(-100, 100);\r
+ progress = update_progress( progress, 4, 14, 0 );\r
runCase<unsigned char, float>(10, 100);\r
+ progress = update_progress( progress, 5, 14, 0 );\r
\r
runCase<float, int>(-100.f, 100.f);\r
+ progress = update_progress( progress, 6, 14, 0 );\r
runCase<int, int>(-100, 100);\r
+ progress = update_progress( progress, 7, 14, 0 );\r
runCase<short, int>(-100, 100);\r
+ progress = update_progress( progress, 8, 14, 0 );\r
runCase<unsigned char, int>(10, 100);\r
+ progress = update_progress( progress, 10, 14, 0 );\r
\r
runCase<float, short>(-100.f, 100.f);\r
+ progress = update_progress( progress, 11, 14, 0 );\r
runCase<int, short>(-100, 100);\r
+ progress = update_progress( progress, 12, 14, 0 );\r
runCase<short, short>(-100, 100);\r
+ progress = update_progress( progress, 13, 14, 0 );\r
runCase<unsigned char, short>(10, 100); \r
+ progress = update_progress( progress, 14, 14, 0 );\r
}\r
\r
template<class U, class V> double error(const Vec<U, 3>& v1, const Vec<V, 3>& v2) const\r
--- /dev/null
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+// By downloading, copying, installing or using the software you agree to this license.\r
+// If you do not agree to this license, do not download, install,\r
+// copy or use the software.\r
+//\r
+//\r
+// License Agreement\r
+// For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.\r
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+// * Redistribution's of source code must retain the above copyright notice,\r
+// this list of conditions and the following disclaimer.\r
+//\r
+// * Redistribution's in binary form must reproduce the above copyright notice,\r
+// this list of conditions and the following disclaimer in the documentation\r
+// and/or other materials provided with the distribution.\r
+//\r
+// * The name of the copyright holders may not be used to endorse or promote products\r
+// derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#include "cvtest.h"\r
+\r
+using namespace cv;\r
+using namespace std;\r
+\r
+\r
+class Differential\r
+{\r
+public: \r
+ typedef Mat_<double> mat_t; \r
+\r
+ Differential(double eps_, const mat_t& rv1_, const mat_t& tv1_, const mat_t& rv2_, const mat_t& tv2_) \r
+ : rv1(rv1_), tv1(tv1_), rv2(rv2_), tv2(tv2_), eps(eps_), ev(3, 1) {}\r
+\r
+ void dRv1(mat_t& dr3_dr1, mat_t& dt3_dr1)\r
+ { \r
+ dr3_dr1.create(3, 3); dt3_dr1.create(3, 3);\r
+ \r
+ for(size_t i = 0; i < 3; ++i) \r
+ {\r
+ ev.setTo(Scalar(0)); ev(i, 0) = eps; \r
+ \r
+ composeRT( rv1 + ev, tv1, rv2, tv2, rv3_p, tv3_p); \r
+ composeRT( rv1 - ev, tv1, rv2, tv2, rv3_m, tv3_m);\r
+\r
+ dr3_dr1.col(i) = rv3_p - rv3_m; \r
+ dt3_dr1.col(i) = tv3_p - tv3_m; \r
+ }\r
+ dr3_dr1 /= 2 * eps; dt3_dr1 /= 2 * eps;\r
+ }\r
+\r
+ void dRv2(mat_t& dr3_dr2, mat_t& dt3_dr2)\r
+ { \r
+ dr3_dr2.create(3, 3); dt3_dr2.create(3, 3);\r
+ \r
+ for(size_t i = 0; i < 3; ++i) \r
+ {\r
+ ev.setTo(Scalar(0)); ev(i, 0) = eps; \r
+ \r
+ composeRT( rv1, tv1, rv2 + ev, tv2, rv3_p, tv3_p); \r
+ composeRT( rv1, tv1, rv2 - ev, tv2, rv3_m, tv3_m);\r
+\r
+ dr3_dr2.col(i) = rv3_p - rv3_m; \r
+ dt3_dr2.col(i) = tv3_p - tv3_m; \r
+ }\r
+ dr3_dr2 /= 2 * eps; dt3_dr2 /= 2 * eps;\r
+ }\r
+\r
+ void dTv1(mat_t& drt3_dt1, mat_t& dt3_dt1)\r
+ { \r
+ drt3_dt1.create(3, 3); dt3_dt1.create(3, 3);\r
+ \r
+ for(size_t i = 0; i < 3; ++i) \r
+ {\r
+ ev.setTo(Scalar(0)); ev(i, 0) = eps; \r
+ \r
+ composeRT( rv1, tv1 + ev, rv2, tv2, rv3_p, tv3_p); \r
+ composeRT( rv1, tv1 - ev, rv2, tv2, rv3_m, tv3_m);\r
+\r
+ drt3_dt1.col(i) = rv3_p - rv3_m; \r
+ dt3_dt1.col(i) = tv3_p - tv3_m; \r
+ }\r
+ drt3_dt1 /= 2 * eps; dt3_dt1 /= 2 * eps;\r
+ }\r
+\r
+ void dTv2(mat_t& dr3_dt2, mat_t& dt3_dt2)\r
+ { \r
+ dr3_dt2.create(3, 3); dt3_dt2.create(3, 3);\r
+ \r
+ for(size_t i = 0; i < 3; ++i) \r
+ {\r
+ ev.setTo(Scalar(0)); ev(i, 0) = eps; \r
+ \r
+ composeRT( rv1, tv1, rv2, tv2 + ev, rv3_p, tv3_p); \r
+ composeRT( rv1, tv1, rv2, tv2 - ev, rv3_m, tv3_m);\r
+\r
+ dr3_dt2.col(i) = rv3_p - rv3_m; \r
+ dt3_dt2.col(i) = tv3_p - tv3_m; \r
+ }\r
+ dr3_dt2 /= 2 * eps; dt3_dt2 /= 2 * eps;\r
+ }\r
+ \r
+private:\r
+ const mat_t& rv1, tv1, rv2, tv2;\r
+ \r
+ Differential& operator=(const Differential&);\r
+ Mat rv3_m, tv3_m, rv3_p, tv3_p; \r
+ Mat_<double> ev;\r
+ double eps;\r
+};\r
+\r
+class CV_composeRT_Test : public CvTest\r
+{\r
+public:\r
+ CV_composeRT_Test()\r
+ : CvTest( "composeRT", "cvComposeRT")\r
+ {\r
+ support_testing_modes = CvTS::CORRECTNESS_CHECK_MODE; \r
+ }\r
+ ~CV_composeRT_Test() {}\r
+protected: \r
+ \r
+ void run(int)\r
+ {\r
+ CvTS& ts = *this->ts;\r
+ ts.set_failed_test_info(CvTS::OK);\r
+ \r
+ Mat_<double> rvec1(3, 1), tvec1(3, 1), rvec2(3, 1), tvec2(3, 1); \r
+\r
+ randu(rvec1, Scalar(0), Scalar(6.29));\r
+ randu(rvec2, Scalar(0), Scalar(6.29));\r
+\r
+ randu(tvec1, Scalar(-2), Scalar(2));\r
+ randu(tvec2, Scalar(-2), Scalar(2));\r
+ \r
+ Mat rvec3, tvec3;\r
+ composeRT(rvec1, tvec1, rvec2, tvec2, rvec3, tvec3);\r
+ \r
+ Mat rvec3_exp, tvec3_exp;\r
+\r
+ Mat rmat1, rmat2;\r
+ Rodrigues(rvec1, rmat1);\r
+ Rodrigues(rvec2, rmat2);\r
+ Rodrigues(rmat2 * rmat1, rvec3_exp);\r
+\r
+ tvec3_exp = rmat2 * tvec1 + tvec2;\r
+\r
+ const double thres = 1e-5;\r
+ if (norm(rvec3_exp, rvec3) > thres || norm(tvec3_exp, tvec3) > thres)\r
+ ts.set_failed_test_info(CvTS::FAIL_BAD_ACCURACY);\r
+\r
+ const double eps = 1e-3;\r
+ Differential diff(eps, rvec1, tvec1, rvec2, tvec2);\r
+ \r
+ Mat dr3dr1, dr3dt1, dr3dr2, dr3dt2, dt3dr1, dt3dt1, dt3dr2, dt3dt2;\r
+\r
+ composeRT(rvec1, tvec1, rvec2, tvec2, rvec3, tvec3, \r
+ dr3dr1, dr3dt1, dr3dr2, dr3dt2, dt3dr1, dt3dt1, dt3dr2, dt3dt2);\r
+ \r
+ Mat_<double> dr3_dr1, dt3_dr1;\r
+ diff.dRv1(dr3_dr1, dt3_dr1);\r
+\r
+ if (norm(dr3_dr1, dr3dr1) > thres || norm(dt3_dr1, dt3dr1) > thres)\r
+ { \r
+ ts.printf( CvTS::LOG, "Invalid derivates by r1\n" );\r
+ ts.set_failed_test_info(CvTS::FAIL_BAD_ACCURACY);\r
+ }\r
+\r
+ Mat_<double> dr3_dr2, dt3_dr2;\r
+ diff.dRv2(dr3_dr2, dt3_dr2);\r
+\r
+ if (norm(dr3_dr2, dr3dr2) > thres || norm(dt3_dr2, dt3dr2) > thres)\r
+ { \r
+ ts.printf( CvTS::LOG, "Invalid derivates by r2\n" );\r
+ ts.set_failed_test_info(CvTS::FAIL_BAD_ACCURACY);\r
+ }\r
+\r
+ Mat_<double> dr3_dt1, dt3_dt1;\r
+ diff.dTv1(dr3_dt1, dt3_dt1);\r
+\r
+ if (norm(dr3_dt1, dr3dt1) > thres || norm(dt3_dt1, dt3dt1) > thres)\r
+ { \r
+ ts.printf( CvTS::LOG, "Invalid derivates by t1\n" );\r
+ ts.set_failed_test_info(CvTS::FAIL_BAD_ACCURACY);\r
+ }\r
+ \r
+ Mat_<double> dr3_dt2, dt3_dt2;\r
+ diff.dTv2(dr3_dt2, dt3_dt2);\r
+\r
+ if (norm(dr3_dt2, dr3dt2) > thres || norm(dt3_dt2, dt3dt2) > thres)\r
+ { \r
+ ts.printf( CvTS::LOG, "Invalid derivates by t2\n" );\r
+ ts.set_failed_test_info(CvTS::FAIL_BAD_ACCURACY);\r
+ }\r
+ } \r
+}; \r
+ \r
+CV_composeRT_Test composeRT_test;\r