diff --git a/modules/core/test/test_operations.cpp b/modules/core/test/test_operations.cpp index e0a2c99991..aea6f229ac 100644 --- a/modules/core/test/test_operations.cpp +++ b/modules/core/test/test_operations.cpp @@ -69,6 +69,7 @@ protected: bool TestVec(); bool TestMatxMultiplication(); bool TestMatxElementwiseDivison(); + bool TestMatMatxCastSum(); bool TestSubMatAccess(); bool TestExp(); bool TestSVD(); @@ -885,6 +886,74 @@ bool CV_OperationsTest::TestMatxMultiplication() return true; } +bool CV_OperationsTest::TestMatMatxCastSum() +{ + try + { + Mat ref1 = (Mat_(3, 1) << 1, 2, 3); + Mat ref2 = (Mat_(3, 1) << 3, 4, 5); + Mat ref3 = Mat::ones(3, 1, CV_64FC1); + + Mat mat = Mat::zeros(3, 1, CV_64FC1); + + Mat tst1 = ref1.clone(); + Mat_ tst2 = ref2.clone(); + Matx tst3(1, 2, 3); + Vec3d tst4(3, 4, 5); + Scalar tst5(1, 2, 3); + Mat res; + + res = mat + tst1; + CHECK_DIFF_FLT(res, ref1); + res = mat + tst2; + CHECK_DIFF_FLT(res, ref2); + res = mat + tst3; + CHECK_DIFF_FLT(res, ref1); + res = mat + tst4; + CHECK_DIFF_FLT(res, ref2); + + res = mat + tst5; + CHECK_DIFF_FLT(res, ref3); + res = mat + 1; + CHECK_DIFF_FLT(res, ref3); + + cv::add(mat, tst1, res); + CHECK_DIFF_FLT(res, ref1); + cv::add(mat, tst2, res); + CHECK_DIFF_FLT(res, ref2); + cv::add(mat, tst3, res); + CHECK_DIFF_FLT(res, ref1); + cv::add(mat, tst4, res); + CHECK_DIFF_FLT(res, ref2); + + cv::add(mat, tst5, res); + CHECK_DIFF_FLT(res, ref3); + cv::add(mat, 1, res); + CHECK_DIFF_FLT(res, ref3); + + res = mat.clone(); res += tst1; + CHECK_DIFF_FLT(res, ref1); + res = mat.clone(); res += tst2; + CHECK_DIFF_FLT(res, ref2); + res = mat.clone(); res += tst3; + CHECK_DIFF_FLT(res, ref1); + res = mat.clone(); res += tst4; + CHECK_DIFF_FLT(res, ref2); + + res = mat.clone(); res += tst5; + CHECK_DIFF_FLT(res, ref3); + res = mat.clone(); res += 1; + CHECK_DIFF_FLT(res, ref3); + } + catch (const test_excep& e) + { + ts->printf(cvtest::TS::LOG, "%s\n", e.s.c_str()); + ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH); + return false; + } + return true; +} + bool CV_OperationsTest::TestMatxElementwiseDivison() { try @@ -1135,6 +1204,9 @@ void CV_OperationsTest::run( int /* start_from */) if (!TestMatxElementwiseDivison()) return; + if (!TestMatMatxCastSum()) + return; + if (!TestSubMatAccess()) return;