mirror of
https://github.com/opencv/opencv.git
synced 2025-06-19 00:46:39 +08:00
Added test for addition of Mat and Matx
This commit is contained in:
parent
c8f59bf1e0
commit
cd169941f2
@ -69,6 +69,7 @@ protected:
|
|||||||
bool TestVec();
|
bool TestVec();
|
||||||
bool TestMatxMultiplication();
|
bool TestMatxMultiplication();
|
||||||
bool TestMatxElementwiseDivison();
|
bool TestMatxElementwiseDivison();
|
||||||
|
bool TestMatMatxCastSum();
|
||||||
bool TestSubMatAccess();
|
bool TestSubMatAccess();
|
||||||
bool TestExp();
|
bool TestExp();
|
||||||
bool TestSVD();
|
bool TestSVD();
|
||||||
@ -885,6 +886,74 @@ bool CV_OperationsTest::TestMatxMultiplication()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CV_OperationsTest::TestMatMatxCastSum()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Mat ref1 = (Mat_<double>(3, 1) << 1, 2, 3);
|
||||||
|
Mat ref2 = (Mat_<double>(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_<double> tst2 = ref2.clone();
|
||||||
|
Matx<double, 3, 1> 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()
|
bool CV_OperationsTest::TestMatxElementwiseDivison()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -1135,6 +1204,9 @@ void CV_OperationsTest::run( int /* start_from */)
|
|||||||
if (!TestMatxElementwiseDivison())
|
if (!TestMatxElementwiseDivison())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!TestMatMatxCastSum())
|
||||||
|
return;
|
||||||
|
|
||||||
if (!TestSubMatAccess())
|
if (!TestSubMatAccess())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user