cv::norm -> cvtest::norm in tests

Conflicts:

	modules/core/src/stat.cpp
This commit is contained in:
Ilya Lavrenov 2014-04-08 01:11:58 +04:00
parent a6ef45aa13
commit aa5326c231
37 changed files with 158 additions and 142 deletions

View File

@ -54,8 +54,8 @@ TEST(Calib3d_Affine3f, accuracy)
cv::Rodrigues(rvec, expected); cv::Rodrigues(rvec, expected);
ASSERT_EQ(0, norm(cv::Mat(affine.matrix, false).colRange(0, 3).rowRange(0, 3) != expected)); ASSERT_EQ(0, cvtest::norm(cv::Mat(affine.matrix, false).colRange(0, 3).rowRange(0, 3) != expected, cv::NORM_L2));
ASSERT_EQ(0, norm(cv::Mat(affine.linear()) != expected)); ASSERT_EQ(0, cvtest::norm(cv::Mat(affine.linear()) != expected, cv::NORM_L2));
cv::Matx33d R = cv::Matx33d::eye(); cv::Matx33d R = cv::Matx33d::eye();
@ -77,7 +77,7 @@ TEST(Calib3d_Affine3f, accuracy)
cv::Mat diff; cv::Mat diff;
cv::absdiff(expected, result.matrix, diff); cv::absdiff(expected, result.matrix, diff);
ASSERT_LT(cv::norm(diff, cv::NORM_INF), 1e-15); ASSERT_LT(cvtest::norm(diff, cv::NORM_INF), 1e-15);
} }
TEST(Calib3d_Affine3f, accuracy_rvec) TEST(Calib3d_Affine3f, accuracy_rvec)
@ -103,6 +103,6 @@ TEST(Calib3d_Affine3f, accuracy_rvec)
cv::Rodrigues(R, vo); cv::Rodrigues(R, vo);
//std::cout << "O:" <<(cv::getTickCount() - s)*1000/cv::getTickFrequency() << std::endl; //std::cout << "O:" <<(cv::getTickCount() - s)*1000/cv::getTickFrequency() << std::endl;
ASSERT_LT(cv::norm(va - vo), 1e-9); ASSERT_LT(cvtest::norm(va, vo, cv::NORM_L2), 1e-9);
} }
} }

View File

@ -108,9 +108,9 @@ bool CV_Affine3D_EstTest::test4Points()
estimateAffine3D(fpts, tpts, aff_est, outliers); estimateAffine3D(fpts, tpts, aff_est, outliers);
const double thres = 1e-3; const double thres = 1e-3;
if (norm(aff_est, aff, NORM_INF) > thres) if (cvtest::norm(aff_est, aff, NORM_INF) > thres)
{ {
//cout << norm(aff_est, aff, NORM_INF) << endl; //cout << cvtest::norm(aff_est, aff, NORM_INF) << endl;
ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH); ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH);
return false; return false;
} }
@ -161,7 +161,7 @@ bool CV_Affine3D_EstTest::testNPoints()
} }
const double thres = 1e-4; const double thres = 1e-4;
if (norm(aff_est, aff, NORM_INF) > thres) if (cvtest::norm(aff_est, aff, NORM_INF) > thres)
{ {
cout << "aff est: " << aff_est << endl; cout << "aff est: " << aff_est << endl;
cout << "aff ref: " << aff << endl; cout << "aff ref: " << aff << endl;

View File

@ -215,7 +215,7 @@ void CV_ProjectPointsTest::prepare_to_validation( int /*test_case_idx*/ )
cvTsProjectPoints( m, vec2, m2v_jac ); cvTsProjectPoints( m, vec2, m2v_jac );
cvTsCopy( vec, vec2 ); cvTsCopy( vec, vec2 );
theta0 = cvNorm( vec2, 0, CV_L2 ); theta0 = cvtest::norm( cvarrtomat(vec2), 0, CV_L2 );
theta1 = fmod( theta0, CV_PI*2 ); theta1 = fmod( theta0, CV_PI*2 );
if( theta1 > CV_PI ) if( theta1 > CV_PI )
@ -225,7 +225,7 @@ void CV_ProjectPointsTest::prepare_to_validation( int /*test_case_idx*/ )
if( calc_jacobians ) if( calc_jacobians )
{ {
//cvInvert( v2m_jac, m2v_jac, CV_SVD ); //cvInvert( v2m_jac, m2v_jac, CV_SVD );
if( cvNorm(&test_mat[OUTPUT][3],0,CV_C) < 1000 ) if( cvtest::norm(cvarrtomat(&test_mat[OUTPUT][3]), 0, CV_C) < 1000 )
{ {
cvTsGEMM( &test_mat[OUTPUT][1], &test_mat[OUTPUT][3], cvTsGEMM( &test_mat[OUTPUT][1], &test_mat[OUTPUT][3],
1, 0, 0, &test_mat[OUTPUT][4], 1, 0, 0, &test_mat[OUTPUT][4],
@ -1112,7 +1112,7 @@ void CV_ProjectPointsTest::run(int)
rightImgPoints[i], valDpdrot, valDpdt, valDpdf, valDpdc, valDpddist, 0 ); rightImgPoints[i], valDpdrot, valDpdt, valDpdf, valDpdc, valDpddist, 0 );
} }
calcdfdx( leftImgPoints, rightImgPoints, dEps, valDpdrot ); calcdfdx( leftImgPoints, rightImgPoints, dEps, valDpdrot );
err = norm( dpdrot, valDpdrot, NORM_INF ); err = cvtest::norm( dpdrot, valDpdrot, NORM_INF );
if( err > 3 ) if( err > 3 )
{ {
ts->printf( cvtest::TS::LOG, "bad dpdrot: too big difference = %g\n", err ); ts->printf( cvtest::TS::LOG, "bad dpdrot: too big difference = %g\n", err );
@ -1130,7 +1130,7 @@ void CV_ProjectPointsTest::run(int)
rightImgPoints[i], valDpdrot, valDpdt, valDpdf, valDpdc, valDpddist, 0 ); rightImgPoints[i], valDpdrot, valDpdt, valDpdf, valDpdc, valDpddist, 0 );
} }
calcdfdx( leftImgPoints, rightImgPoints, dEps, valDpdt ); calcdfdx( leftImgPoints, rightImgPoints, dEps, valDpdt );
if( norm( dpdt, valDpdt, NORM_INF ) > 0.2 ) if( cvtest::norm( dpdt, valDpdt, NORM_INF ) > 0.2 )
{ {
ts->printf( cvtest::TS::LOG, "bad dpdtvec\n" ); ts->printf( cvtest::TS::LOG, "bad dpdtvec\n" );
code = cvtest::TS::FAIL_BAD_ACCURACY; code = cvtest::TS::FAIL_BAD_ACCURACY;
@ -1153,7 +1153,7 @@ void CV_ProjectPointsTest::run(int)
project( objPoints, rvec, tvec, rightCameraMatrix, distCoeffs, project( objPoints, rvec, tvec, rightCameraMatrix, distCoeffs,
rightImgPoints[1], valDpdrot, valDpdt, valDpdf, valDpdc, valDpddist, 0 ); rightImgPoints[1], valDpdrot, valDpdt, valDpdf, valDpdc, valDpddist, 0 );
calcdfdx( leftImgPoints, rightImgPoints, dEps, valDpdf ); calcdfdx( leftImgPoints, rightImgPoints, dEps, valDpdf );
if ( norm( dpdf, valDpdf ) > 0.2 ) if ( cvtest::norm( dpdf, valDpdf, NORM_L2 ) > 0.2 )
{ {
ts->printf( cvtest::TS::LOG, "bad dpdf\n" ); ts->printf( cvtest::TS::LOG, "bad dpdf\n" );
code = cvtest::TS::FAIL_BAD_ACCURACY; code = cvtest::TS::FAIL_BAD_ACCURACY;
@ -1174,7 +1174,7 @@ void CV_ProjectPointsTest::run(int)
project( objPoints, rvec, tvec, rightCameraMatrix, distCoeffs, project( objPoints, rvec, tvec, rightCameraMatrix, distCoeffs,
rightImgPoints[1], valDpdrot, valDpdt, valDpdf, valDpdc, valDpddist, 0 ); rightImgPoints[1], valDpdrot, valDpdt, valDpdf, valDpdc, valDpddist, 0 );
calcdfdx( leftImgPoints, rightImgPoints, dEps, valDpdc ); calcdfdx( leftImgPoints, rightImgPoints, dEps, valDpdc );
if ( norm( dpdc, valDpdc ) > 0.2 ) if ( cvtest::norm( dpdc, valDpdc, NORM_L2 ) > 0.2 )
{ {
ts->printf( cvtest::TS::LOG, "bad dpdc\n" ); ts->printf( cvtest::TS::LOG, "bad dpdc\n" );
code = cvtest::TS::FAIL_BAD_ACCURACY; code = cvtest::TS::FAIL_BAD_ACCURACY;
@ -1193,7 +1193,7 @@ void CV_ProjectPointsTest::run(int)
rightImgPoints[i], valDpdrot, valDpdt, valDpdf, valDpdc, valDpddist, 0 ); rightImgPoints[i], valDpdrot, valDpdt, valDpdf, valDpdc, valDpddist, 0 );
} }
calcdfdx( leftImgPoints, rightImgPoints, dEps, valDpddist ); calcdfdx( leftImgPoints, rightImgPoints, dEps, valDpddist );
if( norm( dpddist, valDpddist ) > 0.3 ) if( cvtest::norm( dpddist, valDpddist, NORM_L2 ) > 0.3 )
{ {
ts->printf( cvtest::TS::LOG, "bad dpddist\n" ); ts->printf( cvtest::TS::LOG, "bad dpddist\n" );
code = cvtest::TS::FAIL_BAD_ACCURACY; code = cvtest::TS::FAIL_BAD_ACCURACY;
@ -1481,8 +1481,8 @@ void CV_StereoCalibrationTest::run( int )
Mat eye33 = Mat::eye(3,3,CV_64F); Mat eye33 = Mat::eye(3,3,CV_64F);
Mat R1t = R1.t(), R2t = R2.t(); Mat R1t = R1.t(), R2t = R2.t();
if( norm(R1t*R1 - eye33) > 0.01 || if( cvtest::norm(R1t*R1 - eye33, NORM_L2) > 0.01 ||
norm(R2t*R2 - eye33) > 0.01 || cvtest::norm(R2t*R2 - eye33, NORM_L2) > 0.01 ||
abs(determinant(F)) > 0.01) abs(determinant(F)) > 0.01)
{ {
ts->printf( cvtest::TS::LOG, "The computed (by rectify) R1 and R2 are not orthogonal," ts->printf( cvtest::TS::LOG, "The computed (by rectify) R1 and R2 are not orthogonal,"
@ -1505,7 +1505,7 @@ void CV_StereoCalibrationTest::run( int )
//check that Tx after rectification is equal to distance between cameras //check that Tx after rectification is equal to distance between cameras
double tx = fabs(P2.at<double>(0, 3) / P2.at<double>(0, 0)); double tx = fabs(P2.at<double>(0, 3) / P2.at<double>(0, 0));
if (fabs(tx - norm(T)) > 1e-5) if (fabs(tx - cvtest::norm(T, NORM_L2)) > 1e-5)
{ {
ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY ); ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );
return; return;
@ -1556,7 +1556,7 @@ void CV_StereoCalibrationTest::run( int )
Mat reprojectedPoints; Mat reprojectedPoints;
perspectiveTransform(sparsePoints, reprojectedPoints, Q); perspectiveTransform(sparsePoints, reprojectedPoints, Q);
if (norm(triangulatedPoints - reprojectedPoints) / sqrt((double)pointsCount) > requiredAccuracy) if (cvtest::norm(triangulatedPoints, reprojectedPoints, NORM_L2) / sqrt((double)pointsCount) > requiredAccuracy)
{ {
ts->printf( cvtest::TS::LOG, "Points reprojected with a matrix Q and points reconstructed by triangulation are different, testcase %d\n", testcase); ts->printf( cvtest::TS::LOG, "Points reprojected with a matrix Q and points reconstructed by triangulation are different, testcase %d\n", testcase);
ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT ); ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );
@ -1581,7 +1581,7 @@ void CV_StereoCalibrationTest::run( int )
{ {
Mat error = newHomogeneousPoints2.row(i) * typedF * newHomogeneousPoints1.row(i).t(); Mat error = newHomogeneousPoints2.row(i) * typedF * newHomogeneousPoints1.row(i).t();
CV_Assert(error.rows == 1 && error.cols == 1); CV_Assert(error.rows == 1 && error.cols == 1);
if (norm(error) > constraintAccuracy) if (cvtest::norm(error, NORM_L2) > constraintAccuracy)
{ {
ts->printf( cvtest::TS::LOG, "Epipolar constraint is violated after correctMatches, testcase %d\n", testcase); ts->printf( cvtest::TS::LOG, "Epipolar constraint is violated after correctMatches, testcase %d\n", testcase);
ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT ); ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );

View File

@ -204,7 +204,7 @@ protected:
Rodrigues(rvecs[i], rmat); Rodrigues(rvecs[i], rmat);
Rodrigues(rvecs_est[i], rmat_est); Rodrigues(rvecs_est[i], rmat_est);
if (norm(rmat_est, rmat) > eps* (norm(rmat) + dlt)) if (cvtest::norm(rmat_est, rmat, NORM_L2) > eps* (cvtest::norm(rmat, NORM_L2) + dlt))
{ {
if (err_count++ < errMsgNum) if (err_count++ < errMsgNum)
{ {
@ -213,7 +213,8 @@ protected:
else else
{ {
ts->printf( cvtest::TS::LOG, "%d) Bad accuracy in returned rvecs (rotation matrs). Index = %d\n", r, i); ts->printf( cvtest::TS::LOG, "%d) Bad accuracy in returned rvecs (rotation matrs). Index = %d\n", r, i);
ts->printf( cvtest::TS::LOG, "%d) norm(rot_mat_est - rot_mat_exp) = %f, norm(rot_mat_exp) = %f \n", r, norm(rmat_est, rmat), norm(rmat)); ts->printf( cvtest::TS::LOG, "%d) norm(rot_mat_est - rot_mat_exp) = %f, norm(rot_mat_exp) = %f \n", r,
cvtest::norm(rmat_est, rmat, NORM_L2), cvtest::norm(rmat, NORM_L2));
} }
} }

View File

@ -738,7 +738,7 @@ void CV_RodriguesTest::prepare_to_validation( int /*test_case_idx*/ )
if( calc_jacobians ) if( calc_jacobians )
{ {
//cvInvert( v2m_jac, m2v_jac, CV_SVD ); //cvInvert( v2m_jac, m2v_jac, CV_SVD );
double nrm = norm(test_mat[REF_OUTPUT][3],CV_C); double nrm = cvtest::norm(test_mat[REF_OUTPUT][3], CV_C);
if( FLT_EPSILON < nrm && nrm < 1000 ) if( FLT_EPSILON < nrm && nrm < 1000 )
{ {
gemm( test_mat[OUTPUT][1], test_mat[OUTPUT][3], gemm( test_mat[OUTPUT][1], test_mat[OUTPUT][3],
@ -1409,8 +1409,8 @@ void CV_EssentialMatTest::prepare_to_validation( int test_case_idx )
double* pose_prop1 = (double*)test_mat[REF_OUTPUT][2].data; double* pose_prop1 = (double*)test_mat[REF_OUTPUT][2].data;
double* pose_prop2 = (double*)test_mat[OUTPUT][2].data; double* pose_prop2 = (double*)test_mat[OUTPUT][2].data;
double terr1 = norm(Rt0.col(3) / norm(Rt0.col(3)) + test_mat[TEMP][3]); double terr1 = cvtest::norm(Rt0.col(3) / norm(Rt0.col(3)) + test_mat[TEMP][3], NORM_L2);
double terr2 = norm(Rt0.col(3) / norm(Rt0.col(3)) - test_mat[TEMP][3]); double terr2 = cvtest::norm(Rt0.col(3) / norm(Rt0.col(3)) - test_mat[TEMP][3], NORM_L2);
Mat rvec; Mat rvec;
Rodrigues(Rt0.colRange(0, 3), rvec); Rodrigues(Rt0.colRange(0, 3), rvec);
pose_prop1[0] = 0; pose_prop1[0] = 0;

View File

@ -119,7 +119,7 @@ bool CV_HomographyTest::check_matrix_size(const cv::Mat& H)
bool CV_HomographyTest::check_matrix_diff(const cv::Mat& original, const cv::Mat& found, const int norm_type, double &diff) bool CV_HomographyTest::check_matrix_diff(const cv::Mat& original, const cv::Mat& found, const int norm_type, double &diff)
{ {
diff = cv::norm(original, found, norm_type); diff = cvtest::norm(original, found, norm_type);
return diff <= max_diff; return diff <= max_diff;
} }

View File

@ -299,8 +299,8 @@ TEST(DISABLED_Calib3d_SolvePnPRansac, concurrency)
solvePnPRansac(object, image, camera_mat, dist_coef, rvec2, tvec2); solvePnPRansac(object, image, camera_mat, dist_coef, rvec2, tvec2);
} }
double rnorm = cv::norm(rvec1, rvec2, NORM_INF); double rnorm = cvtest::norm(rvec1, rvec2, NORM_INF);
double tnorm = cv::norm(tvec1, tvec2, NORM_INF); double tnorm = cvtest::norm(tvec1, tvec2, NORM_INF);
EXPECT_LT(rnorm, 1e-6); EXPECT_LT(rnorm, 1e-6);
EXPECT_LT(tnorm, 1e-6); EXPECT_LT(tnorm, 1e-6);

View File

@ -279,7 +279,7 @@ float dispRMS( const Mat& computedDisp, const Mat& groundTruthDisp, const Mat& m
checkTypeAndSizeOfMask( mask, sz ); checkTypeAndSizeOfMask( mask, sz );
pointsCount = countNonZero(mask); pointsCount = countNonZero(mask);
} }
return 1.f/sqrt((float)pointsCount) * (float)norm(computedDisp, groundTruthDisp, NORM_L2, mask); return 1.f/sqrt((float)pointsCount) * (float)cvtest::norm(computedDisp, groundTruthDisp, NORM_L2, mask);
} }
/* /*

View File

@ -84,7 +84,7 @@ void CV_UndistortTest::run(int /* start_from */)
Mat p; Mat p;
perspectiveTransform(undistortedPoints, p, intrinsics); perspectiveTransform(undistortedPoints, p, intrinsics);
undistortedPoints = p; undistortedPoints = p;
double diff = norm(Mat(realUndistortedPoints), undistortedPoints); double diff = cvtest::norm(Mat(realUndistortedPoints), undistortedPoints, NORM_L2);
if (diff > thresh) if (diff > thresh)
{ {
ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY); ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);

View File

@ -2364,7 +2364,7 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) #if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat(); Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat();
normType &= 7; normType &= NORM_TYPE_MASK;
CV_Assert( normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR || CV_Assert( normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR ||
((normType == NORM_HAMMING || normType == NORM_HAMMING2) && src1.type() == CV_8U) ); ((normType == NORM_HAMMING || normType == NORM_HAMMING2) && src1.type() == CV_8U) );
size_t total_size = src1.total(); size_t total_size = src1.total();

View File

@ -1362,7 +1362,8 @@ TEST_P(ElemWiseTest, accuracy)
double maxErr = op->getMaxErr(depth); double maxErr = op->getMaxErr(depth);
vector<int> pos; vector<int> pos;
ASSERT_PRED_FORMAT2(cvtest::MatComparator(maxErr, op->context), dst0, dst) << "\nsrc[0] ~ " << cvtest::MatInfo(!src.empty() ? src[0] : Mat()) << "\ntestCase #" << testIdx << "\n"; ASSERT_PRED_FORMAT2(cvtest::MatComparator(maxErr, op->context), dst0, dst) << "\nsrc[0] ~ " <<
cvtest::MatInfo(!src.empty() ? src[0] : Mat()) << "\ntestCase #" << testIdx << "\n";
} }
} }
@ -1500,7 +1501,7 @@ protected:
} }
Mat d1; Mat d1;
d.convertTo(d1, depth); d.convertTo(d1, depth);
CV_Assert( norm(c, d1, CV_C) <= DBL_EPSILON ); CV_Assert( cvtest::norm(c, d1, CV_C) <= DBL_EPSILON );
} }
Mat_<uchar> tmpSrc(100,100); Mat_<uchar> tmpSrc(100,100);
@ -1574,7 +1575,7 @@ TEST_P(Mul1, One)
cv::multiply(3, src, dst); cv::multiply(3, src, dst);
ASSERT_EQ(0, cv::norm(dst, ref_dst, cv::NORM_INF)); ASSERT_EQ(0, cvtest::norm(dst, ref_dst, cv::NORM_INF));
} }
INSTANTIATE_TEST_CASE_P(Arithm, Mul1, testing::Values(Size(2, 2), Size(1, 1))); INSTANTIATE_TEST_CASE_P(Arithm, Mul1, testing::Values(Size(2, 2), Size(1, 1)));

View File

@ -855,7 +855,7 @@ protected:
merge(mv, 2, srcz); merge(mv, 2, srcz);
dft(srcz, dstz); dft(srcz, dstz);
dft(src, dst, DFT_COMPLEX_OUTPUT); dft(src, dst, DFT_COMPLEX_OUTPUT);
if(norm(dst, dstz, NORM_INF) > 1e-3) if (cvtest::norm(dst, dstz, NORM_INF) > 1e-3)
{ {
cout << "actual:\n" << dst << endl << endl; cout << "actual:\n" << dst << endl << endl;
cout << "reference:\n" << dstz << endl << endl; cout << "reference:\n" << dstz << endl << endl;

View File

@ -175,7 +175,7 @@ bool Core_EigenTest::check_pair_count(const cv::Mat& src, const cv::Mat& evalues
{ {
std::cout << endl; std::cout << "Checking sizes of eigen values matrix " << evalues << "..." << endl; std::cout << endl; std::cout << "Checking sizes of eigen values matrix " << evalues << "..." << endl;
std::cout << "Number of rows: " << evalues.rows << " Number of cols: " << evalues.cols << endl; std::cout << "Number of rows: " << evalues.rows << " Number of cols: " << evalues.cols << endl;
std:: cout << "Size of src symmetric matrix: " << src.rows << " * " << src.cols << endl; std::cout << endl; std::cout << "Size of src symmetric matrix: " << src.rows << " * " << src.cols << endl; std::cout << endl;
CV_Error(CORE_EIGEN_ERROR_COUNT, MESSAGE_ERROR_COUNT); CV_Error(CORE_EIGEN_ERROR_COUNT, MESSAGE_ERROR_COUNT);
return false; return false;
} }
@ -187,7 +187,7 @@ bool Core_EigenTest::check_pair_count(const cv::Mat& src, const cv::Mat& evalues
int n = src.rows, s = sign(high_index); int n = src.rows, s = sign(high_index);
int right_eigen_pair_count = n - max<int>(0, low_index) - ((int)((n/2.0)*(s*s-s)) + (1+s-s*s)*(n - (high_index+1))); int right_eigen_pair_count = n - max<int>(0, low_index) - ((int)((n/2.0)*(s*s-s)) + (1+s-s*s)*(n - (high_index+1)));
if (!((evectors.rows == right_eigen_pair_count) && (evectors.cols == right_eigen_pair_count))) if (!(evectors.rows == right_eigen_pair_count && evectors.cols == right_eigen_pair_count))
{ {
std::cout << endl; std::cout << "Checking sizes of eigen vectors matrix " << evectors << "..." << endl; std::cout << endl; std::cout << "Checking sizes of eigen vectors matrix " << evectors << "..." << endl;
std::cout << "Number of rows: " << evectors.rows << " Number of cols: " << evectors.cols << endl; std::cout << "Number of rows: " << evectors.rows << " Number of cols: " << evectors.cols << endl;
@ -196,7 +196,7 @@ bool Core_EigenTest::check_pair_count(const cv::Mat& src, const cv::Mat& evalues
return false; return false;
} }
if (!((evalues.rows == right_eigen_pair_count) && (evalues.cols == 1))) if (!(evalues.rows == right_eigen_pair_count && evalues.cols == 1))
{ {
std::cout << endl; std::cout << "Checking sizes of eigen values matrix " << evalues << "..." << endl; std::cout << endl; std::cout << "Checking sizes of eigen values matrix " << evalues << "..." << endl;
std::cout << "Number of rows: " << evalues.rows << " Number of cols: " << evalues.cols << endl; std::cout << "Number of rows: " << evalues.rows << " Number of cols: " << evalues.cols << endl;
@ -212,9 +212,9 @@ void Core_EigenTest::print_information(const size_t norm_idx, const cv::Mat& src
{ {
switch (NORM_TYPE[norm_idx]) switch (NORM_TYPE[norm_idx])
{ {
case cv::NORM_L1: {std::cout << "L1"; break;} case cv::NORM_L1: std::cout << "L1"; break;
case cv::NORM_L2: {std::cout << "L2"; break;} case cv::NORM_L2: std::cout << "L2"; break;
case cv::NORM_INF: {std::cout << "INF"; break;} case cv::NORM_INF: std::cout << "INF"; break;
default: break; default: break;
} }
@ -234,7 +234,7 @@ bool Core_EigenTest::check_orthogonality(const cv::Mat& U)
for (int i = 0; i < COUNT_NORM_TYPES; ++i) for (int i = 0; i < COUNT_NORM_TYPES; ++i)
{ {
double diff = cv::norm(UUt, E, NORM_TYPE[i]); double diff = cvtest::norm(UUt, E, NORM_TYPE[i]);
if (diff > eps_vec) if (diff > eps_vec)
{ {
std::cout << endl; std::cout << "Checking orthogonality of matrix " << U << ": "; std::cout << endl; std::cout << "Checking orthogonality of matrix " << U << ": ";
@ -271,12 +271,12 @@ bool Core_EigenTest::check_pairs_order(const cv::Mat& eigen_values)
for (int i = 0; i < (int)(eigen_values.total() - 1); ++i) for (int i = 0; i < (int)(eigen_values.total() - 1); ++i)
if (!(eigen_values.at<double>(i, 0) > eigen_values.at<double>(i+1, 0))) if (!(eigen_values.at<double>(i, 0) > eigen_values.at<double>(i+1, 0)))
{ {
std::cout << endl; std::cout << "Checking order of eigen values vector " << eigen_values << "..." << endl; std::cout << endl; std::cout << "Checking order of eigen values vector " << eigen_values << "..." << endl;
std::cout << "Pair of indexes with non ascending of eigen values: (" << i << ", " << i+1 << ")." << endl; std::cout << "Pair of indexes with non ascending of eigen values: (" << i << ", " << i+1 << ")." << endl;
std::cout << endl; std::cout << endl;
CV_Error(CORE_EIGEN_ERROR_ORDER, "Eigen values are not sorted in ascending order."); CV_Error(CORE_EIGEN_ERROR_ORDER, "Eigen values are not sorted in ascending order.");
return false; return false;
} }
break; break;
} }
@ -296,11 +296,14 @@ bool Core_EigenTest::test_pairs(const cv::Mat& src)
cv::eigen(src, eigen_values, eigen_vectors); cv::eigen(src, eigen_values, eigen_vectors);
if (!check_pair_count(src, eigen_values, eigen_vectors)) return false; if (!check_pair_count(src, eigen_values, eigen_vectors))
return false;
if (!check_orthogonality (eigen_vectors)) return false; if (!check_orthogonality (eigen_vectors))
return false;
if (!check_pairs_order(eigen_values)) return false; if (!check_pairs_order(eigen_values))
return false;
cv::Mat eigen_vectors_t; cv::transpose(eigen_vectors, eigen_vectors_t); cv::Mat eigen_vectors_t; cv::transpose(eigen_vectors, eigen_vectors_t);
@ -340,7 +343,7 @@ bool Core_EigenTest::test_pairs(const cv::Mat& src)
for (int i = 0; i < COUNT_NORM_TYPES; ++i) for (int i = 0; i < COUNT_NORM_TYPES; ++i)
{ {
double diff = cv::norm(disparity, NORM_TYPE[i]); double diff = cvtest::norm(disparity, NORM_TYPE[i]);
if (diff > eps_vec) if (diff > eps_vec)
{ {
std::cout << endl; std::cout << "Checking accuracy of eigen vectors computing for matrix " << src << ": "; std::cout << endl; std::cout << "Checking accuracy of eigen vectors computing for matrix " << src << ": ";
@ -369,7 +372,7 @@ bool Core_EigenTest::test_values(const cv::Mat& src)
for (int i = 0; i < COUNT_NORM_TYPES; ++i) for (int i = 0; i < COUNT_NORM_TYPES; ++i)
{ {
double diff = cv::norm(eigen_values_1, eigen_values_2, NORM_TYPE[i]); double diff = cvtest::norm(eigen_values_1, eigen_values_2, NORM_TYPE[i]);
if (diff > eps_val) if (diff > eps_val)
{ {
std::cout << endl; std::cout << "Checking accuracy of eigen values computing for matrix " << src << ": "; std::cout << endl; std::cout << "Checking accuracy of eigen values computing for matrix " << src << ": ";

View File

@ -480,9 +480,9 @@ protected:
fs["g1"] >> og1; fs["g1"] >> og1;
CV_Assert( mi2.empty() ); CV_Assert( mi2.empty() );
CV_Assert( mv2.empty() ); CV_Assert( mv2.empty() );
CV_Assert( norm(mi3, mi4, CV_C) == 0 ); CV_Assert( cvtest::norm(Mat(mi3), Mat(mi4), CV_C) == 0 );
CV_Assert( mv4.size() == 1 ); CV_Assert( mv4.size() == 1 );
double n = norm(mv3[0], mv4[0], CV_C); double n = cvtest::norm(mv3[0], mv4[0], CV_C);
CV_Assert( vudt2.empty() ); CV_Assert( vudt2.empty() );
CV_Assert( vudt3 == vudt4 ); CV_Assert( vudt3 == vudt4 );
CV_Assert( n == 0 ); CV_Assert( n == 0 );

View File

@ -340,7 +340,7 @@ protected:
Mat Qv = Q * v; Mat Qv = Q * v;
Mat lv = eval.at<float>(i,0) * v; Mat lv = eval.at<float>(i,0) * v;
err = norm( Qv, lv ); err = cvtest::norm( Qv, lv, NORM_L2 );
if( err > eigenEps ) if( err > eigenEps )
{ {
ts->printf( cvtest::TS::LOG, "bad accuracy of eigen(); err = %f\n", err ); ts->printf( cvtest::TS::LOG, "bad accuracy of eigen(); err = %f\n", err );
@ -350,7 +350,7 @@ protected:
} }
// check pca eigenvalues // check pca eigenvalues
evalEps = 1e-6, evecEps = 1e-3; evalEps = 1e-6, evecEps = 1e-3;
err = norm( rPCA.eigenvalues, subEval ); err = cvtest::norm( rPCA.eigenvalues, subEval, NORM_L2 );
if( err > evalEps ) if( err > evalEps )
{ {
ts->printf( cvtest::TS::LOG, "pca.eigenvalues is incorrect (CV_PCA_DATA_AS_ROW); err = %f\n", err ); ts->printf( cvtest::TS::LOG, "pca.eigenvalues is incorrect (CV_PCA_DATA_AS_ROW); err = %f\n", err );
@ -362,11 +362,11 @@ protected:
{ {
Mat r0 = rPCA.eigenvectors.row(i); Mat r0 = rPCA.eigenvectors.row(i);
Mat r1 = subEvec.row(i); Mat r1 = subEvec.row(i);
err = norm( r0, r1, CV_L2 ); err = cvtest::norm( r0, r1, CV_L2 );
if( err > evecEps ) if( err > evecEps )
{ {
r1 *= -1; r1 *= -1;
double err2 = norm(r0, r1, CV_L2); double err2 = cvtest::norm(r0, r1, CV_L2);
if( err2 > evecEps ) if( err2 > evecEps )
{ {
Mat tmp; Mat tmp;
@ -390,7 +390,7 @@ protected:
// check pca project // check pca project
Mat subEvec_t = subEvec.t(); Mat subEvec_t = subEvec.t();
Mat prj = rTestPoints.row(i) - avg; prj *= subEvec_t; Mat prj = rTestPoints.row(i) - avg; prj *= subEvec_t;
err = norm(rPrjTestPoints.row(i), prj, CV_RELATIVE_L2); err = cvtest::norm(rPrjTestPoints.row(i), prj, CV_RELATIVE_L2);
if( err > prjEps ) if( err > prjEps )
{ {
ts->printf( cvtest::TS::LOG, "bad accuracy of project() (CV_PCA_DATA_AS_ROW); err = %f\n", err ); ts->printf( cvtest::TS::LOG, "bad accuracy of project() (CV_PCA_DATA_AS_ROW); err = %f\n", err );
@ -399,7 +399,7 @@ protected:
} }
// check pca backProject // check pca backProject
Mat backPrj = rPrjTestPoints.row(i) * subEvec + avg; Mat backPrj = rPrjTestPoints.row(i) * subEvec + avg;
err = norm( rBackPrjTestPoints.row(i), backPrj, CV_RELATIVE_L2 ); err = cvtest::norm( rBackPrjTestPoints.row(i), backPrj, CV_RELATIVE_L2 );
if( err > backPrjEps ) if( err > backPrjEps )
{ {
ts->printf( cvtest::TS::LOG, "bad accuracy of backProject() (CV_PCA_DATA_AS_ROW); err = %f\n", err ); ts->printf( cvtest::TS::LOG, "bad accuracy of backProject() (CV_PCA_DATA_AS_ROW); err = %f\n", err );
@ -412,14 +412,14 @@ protected:
cPCA( rPoints.t(), Mat(), CV_PCA_DATA_AS_COL, maxComponents ); cPCA( rPoints.t(), Mat(), CV_PCA_DATA_AS_COL, maxComponents );
diffPrjEps = 1, diffBackPrjEps = 1; diffPrjEps = 1, diffBackPrjEps = 1;
Mat ocvPrjTestPoints = cPCA.project(rTestPoints.t()); Mat ocvPrjTestPoints = cPCA.project(rTestPoints.t());
err = norm(cv::abs(ocvPrjTestPoints), cv::abs(rPrjTestPoints.t()), CV_RELATIVE_L2 ); err = cvtest::norm(cv::abs(ocvPrjTestPoints), cv::abs(rPrjTestPoints.t()), CV_RELATIVE_L2 );
if( err > diffPrjEps ) if( err > diffPrjEps )
{ {
ts->printf( cvtest::TS::LOG, "bad accuracy of project() (CV_PCA_DATA_AS_COL); err = %f\n", err ); ts->printf( cvtest::TS::LOG, "bad accuracy of project() (CV_PCA_DATA_AS_COL); err = %f\n", err );
ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY ); ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );
return; return;
} }
err = norm(cPCA.backProject(ocvPrjTestPoints), rBackPrjTestPoints.t(), CV_RELATIVE_L2 ); err = cvtest::norm(cPCA.backProject(ocvPrjTestPoints), rBackPrjTestPoints.t(), CV_RELATIVE_L2 );
if( err > diffBackPrjEps ) if( err > diffBackPrjEps )
{ {
ts->printf( cvtest::TS::LOG, "bad accuracy of backProject() (CV_PCA_DATA_AS_COL); err = %f\n", err ); ts->printf( cvtest::TS::LOG, "bad accuracy of backProject() (CV_PCA_DATA_AS_COL); err = %f\n", err );
@ -433,9 +433,9 @@ protected:
Mat rvPrjTestPoints = cPCA.project(rTestPoints.t()); Mat rvPrjTestPoints = cPCA.project(rTestPoints.t());
if( cPCA.eigenvectors.rows > maxComponents) if( cPCA.eigenvectors.rows > maxComponents)
err = norm(cv::abs(rvPrjTestPoints.rowRange(0,maxComponents)), cv::abs(rPrjTestPoints.t()), CV_RELATIVE_L2 ); err = cvtest::norm(cv::abs(rvPrjTestPoints.rowRange(0,maxComponents)), cv::abs(rPrjTestPoints.t()), CV_RELATIVE_L2 );
else else
err = norm(cv::abs(rvPrjTestPoints), cv::abs(rPrjTestPoints.colRange(0,cPCA.eigenvectors.rows).t()), CV_RELATIVE_L2 ); err = cvtest::norm(cv::abs(rvPrjTestPoints), cv::abs(rPrjTestPoints.colRange(0,cPCA.eigenvectors.rows).t()), CV_RELATIVE_L2 );
if( err > diffPrjEps ) if( err > diffPrjEps )
{ {
@ -443,7 +443,7 @@ protected:
ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY ); ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );
return; return;
} }
err = norm(cPCA.backProject(rvPrjTestPoints), rBackPrjTestPoints.t(), CV_RELATIVE_L2 ); err = cvtest::norm(cPCA.backProject(rvPrjTestPoints), rBackPrjTestPoints.t(), CV_RELATIVE_L2 );
if( err > diffBackPrjEps ) if( err > diffBackPrjEps )
{ {
ts->printf( cvtest::TS::LOG, "bad accuracy of backProject() (CV_PCA_DATA_AS_COL); retainedVariance=0.95; err = %f\n", err ); ts->printf( cvtest::TS::LOG, "bad accuracy of backProject() (CV_PCA_DATA_AS_COL); retainedVariance=0.95; err = %f\n", err );
@ -467,14 +467,14 @@ protected:
cvProjectPCA( &_testPoints, &_avg, &_evec, &_prjTestPoints ); cvProjectPCA( &_testPoints, &_avg, &_evec, &_prjTestPoints );
cvBackProjectPCA( &_prjTestPoints, &_avg, &_evec, &_backPrjTestPoints ); cvBackProjectPCA( &_prjTestPoints, &_avg, &_evec, &_backPrjTestPoints );
err = norm(prjTestPoints, rPrjTestPoints, CV_RELATIVE_L2); err = cvtest::norm(prjTestPoints, rPrjTestPoints, CV_RELATIVE_L2);
if( err > diffPrjEps ) if( err > diffPrjEps )
{ {
ts->printf( cvtest::TS::LOG, "bad accuracy of cvProjectPCA() (CV_PCA_DATA_AS_ROW); err = %f\n", err ); ts->printf( cvtest::TS::LOG, "bad accuracy of cvProjectPCA() (CV_PCA_DATA_AS_ROW); err = %f\n", err );
ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY ); ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );
return; return;
} }
err = norm(backPrjTestPoints, rBackPrjTestPoints, CV_RELATIVE_L2); err = cvtest::norm(backPrjTestPoints, rBackPrjTestPoints, CV_RELATIVE_L2);
if( err > diffBackPrjEps ) if( err > diffBackPrjEps )
{ {
ts->printf( cvtest::TS::LOG, "bad accuracy of cvBackProjectPCA() (CV_PCA_DATA_AS_ROW); err = %f\n", err ); ts->printf( cvtest::TS::LOG, "bad accuracy of cvBackProjectPCA() (CV_PCA_DATA_AS_ROW); err = %f\n", err );
@ -495,14 +495,14 @@ protected:
cvProjectPCA( &_testPoints, &_avg, &_evec, &_prjTestPoints ); cvProjectPCA( &_testPoints, &_avg, &_evec, &_prjTestPoints );
cvBackProjectPCA( &_prjTestPoints, &_avg, &_evec, &_backPrjTestPoints ); cvBackProjectPCA( &_prjTestPoints, &_avg, &_evec, &_backPrjTestPoints );
err = norm(cv::abs(prjTestPoints), cv::abs(rPrjTestPoints.t()), CV_RELATIVE_L2 ); err = cvtest::norm(cv::abs(prjTestPoints), cv::abs(rPrjTestPoints.t()), CV_RELATIVE_L2 );
if( err > diffPrjEps ) if( err > diffPrjEps )
{ {
ts->printf( cvtest::TS::LOG, "bad accuracy of cvProjectPCA() (CV_PCA_DATA_AS_COL); err = %f\n", err ); ts->printf( cvtest::TS::LOG, "bad accuracy of cvProjectPCA() (CV_PCA_DATA_AS_COL); err = %f\n", err );
ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY ); ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );
return; return;
} }
err = norm(backPrjTestPoints, rBackPrjTestPoints.t(), CV_RELATIVE_L2); err = cvtest::norm(backPrjTestPoints, rBackPrjTestPoints.t(), CV_RELATIVE_L2);
if( err > diffBackPrjEps ) if( err > diffBackPrjEps )
{ {
ts->printf( cvtest::TS::LOG, "bad accuracy of cvBackProjectPCA() (CV_PCA_DATA_AS_COL); err = %f\n", err ); ts->printf( cvtest::TS::LOG, "bad accuracy of cvBackProjectPCA() (CV_PCA_DATA_AS_COL); err = %f\n", err );
@ -518,19 +518,19 @@ protected:
PCA lPCA; PCA lPCA;
fs.open( "PCA_store.yml", FileStorage::READ ); fs.open( "PCA_store.yml", FileStorage::READ );
lPCA.read( fs.root() ); lPCA.read( fs.root() );
err = norm( rPCA.eigenvectors, lPCA.eigenvectors, CV_RELATIVE_L2 ); err = cvtest::norm( rPCA.eigenvectors, lPCA.eigenvectors, CV_RELATIVE_L2 );
if( err > 0 ) if( err > 0 )
{ {
ts->printf( cvtest::TS::LOG, "bad accuracy of write/load functions (YML); err = %f\n", err ); ts->printf( cvtest::TS::LOG, "bad accuracy of write/load functions (YML); err = %f\n", err );
ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY ); ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );
} }
err = norm( rPCA.eigenvalues, lPCA.eigenvalues, CV_RELATIVE_L2 ); err = cvtest::norm( rPCA.eigenvalues, lPCA.eigenvalues, CV_RELATIVE_L2 );
if( err > 0 ) if( err > 0 )
{ {
ts->printf( cvtest::TS::LOG, "bad accuracy of write/load functions (YML); err = %f\n", err ); ts->printf( cvtest::TS::LOG, "bad accuracy of write/load functions (YML); err = %f\n", err );
ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY ); ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );
} }
err = norm( rPCA.mean, lPCA.mean, CV_RELATIVE_L2 ); err = cvtest::norm( rPCA.mean, lPCA.mean, CV_RELATIVE_L2 );
if( err > 0 ) if( err > 0 )
{ {
ts->printf( cvtest::TS::LOG, "bad accuracy of write/load functions (YML); err = %f\n", err ); ts->printf( cvtest::TS::LOG, "bad accuracy of write/load functions (YML); err = %f\n", err );
@ -731,9 +731,9 @@ void Core_ArrayOpTest::run( int /* start_from */)
} }
minMaxLoc(_all_vals, &min_val, &max_val); minMaxLoc(_all_vals, &min_val, &max_val);
double _norm0 = norm(_all_vals, CV_C); double _norm0 = cvtest::norm(_all_vals, CV_C);
double _norm1 = norm(_all_vals, CV_L1); double _norm1 = cvtest::norm(_all_vals, CV_L1);
double _norm2 = norm(_all_vals, CV_L2); double _norm2 = cvtest::norm(_all_vals, CV_L2);
for( i = 0; i < nz0; i++ ) for( i = 0; i < nz0; i++ )
{ {

View File

@ -2433,7 +2433,7 @@ protected:
} }
Mat convertedRes = resInRad * 180. / CV_PI; Mat convertedRes = resInRad * 180. / CV_PI;
double normDiff = norm(convertedRes - resInDeg, NORM_INF); double normDiff = cvtest::norm(convertedRes - resInDeg, NORM_INF);
if(normDiff > FLT_EPSILON * 180.) if(normDiff > FLT_EPSILON * 180.)
{ {
ts->printf(cvtest::TS::LOG, "There are incorrect result angles (in radians)\n"); ts->printf(cvtest::TS::LOG, "There are incorrect result angles (in radians)\n");
@ -2569,11 +2569,11 @@ TEST(Core_Invert, small)
cv::Mat b = a.t()*a; cv::Mat b = a.t()*a;
cv::Mat c, i = Mat_<float>::eye(3, 3); cv::Mat c, i = Mat_<float>::eye(3, 3);
cv::invert(b, c, cv::DECOMP_LU); //std::cout << b*c << std::endl; cv::invert(b, c, cv::DECOMP_LU); //std::cout << b*c << std::endl;
ASSERT_LT( cv::norm(b*c, i, CV_C), 0.1 ); ASSERT_LT( cvtest::norm(b*c, i, CV_C), 0.1 );
cv::invert(b, c, cv::DECOMP_SVD); //std::cout << b*c << std::endl; cv::invert(b, c, cv::DECOMP_SVD); //std::cout << b*c << std::endl;
ASSERT_LT( cv::norm(b*c, i, CV_C), 0.1 ); ASSERT_LT( cvtest::norm(b*c, i, CV_C), 0.1 );
cv::invert(b, c, cv::DECOMP_CHOLESKY); //std::cout << b*c << std::endl; cv::invert(b, c, cv::DECOMP_CHOLESKY); //std::cout << b*c << std::endl;
ASSERT_LT( cv::norm(b*c, i, CV_C), 0.1 ); ASSERT_LT( cvtest::norm(b*c, i, CV_C), 0.1 );
} }
///////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////
@ -2621,7 +2621,7 @@ TEST(Core_SVD, flt)
Mat X, B1; Mat X, B1;
solve(A, B, X, DECOMP_SVD); solve(A, B, X, DECOMP_SVD);
B1 = A*X; B1 = A*X;
EXPECT_LE(norm(B1, B, NORM_L2 + NORM_RELATIVE), FLT_EPSILON*10); EXPECT_LE(cvtest::norm(B1, B, NORM_L2 + NORM_RELATIVE), FLT_EPSILON*10);
} }

View File

@ -83,11 +83,11 @@ protected:
void checkDiff(const Mat& m1, const Mat& m2, const string& s) void checkDiff(const Mat& m1, const Mat& m2, const string& s)
{ {
if (norm(m1, m2, NORM_INF) != 0) throw test_excep(s); if (cvtest::norm(m1, m2, NORM_INF) != 0) throw test_excep(s);
} }
void checkDiffF(const Mat& m1, const Mat& m2, const string& s) void checkDiffF(const Mat& m1, const Mat& m2, const string& s)
{ {
if (norm(m1, m2, NORM_INF) > 1e-5) throw test_excep(s); if (cvtest::norm(m1, m2, NORM_INF) > 1e-5) throw test_excep(s);
} }
}; };
@ -488,7 +488,7 @@ bool CV_OperationsTest::TestSubMatAccess()
coords.push_back(T_bs(i)); coords.push_back(T_bs(i));
//std::cout << T_bs1(i) << std::endl; //std::cout << T_bs1(i) << std::endl;
} }
CV_Assert( norm(coords, T_bs.reshape(1,1), NORM_INF) == 0 ); CV_Assert( cvtest::norm(coords, T_bs.reshape(1,1), NORM_INF) == 0 );
} }
catch (const test_excep& e) catch (const test_excep& e)
{ {
@ -776,14 +776,14 @@ bool CV_OperationsTest::TestTemplateMat()
mvf.push_back(Mat_<float>::zeros(4, 3)); mvf.push_back(Mat_<float>::zeros(4, 3));
merge(mvf, mf2); merge(mvf, mf2);
split(mf2, mvf2); split(mf2, mvf2);
CV_Assert( norm(mvf2[0], mvf[0], CV_C) == 0 && CV_Assert( cvtest::norm(mvf2[0], mvf[0], CV_C) == 0 &&
norm(mvf2[1], mvf[1], CV_C) == 0 ); cvtest::norm(mvf2[1], mvf[1], CV_C) == 0 );
{ {
Mat a(2,2,CV_32F,1.f); Mat a(2,2,CV_32F,1.f);
Mat b(1,2,CV_32F,1.f); Mat b(1,2,CV_32F,1.f);
Mat c = (a*b.t()).t(); Mat c = (a*b.t()).t();
CV_Assert( norm(c, CV_L1) == 4. ); CV_Assert( cvtest::norm(c, CV_L1) == 4. );
} }
bool badarg_catched = false; bool badarg_catched = false;
@ -988,7 +988,7 @@ bool CV_OperationsTest::operations1()
Vec<double,10> v10dzero; Vec<double,10> v10dzero;
for (int ii = 0; ii < 10; ++ii) { for (int ii = 0; ii < 10; ++ii) {
if (!v10dzero[ii] == 0.0) if (v10dzero[ii] != 0.0)
throw test_excep(); throw test_excep();
} }
@ -1014,13 +1014,13 @@ bool CV_OperationsTest::operations1()
Matx33f b(1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f); Matx33f b(1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f);
Mat c; Mat c;
add(Mat::zeros(3, 3, CV_32F), b, c); add(Mat::zeros(3, 3, CV_32F), b, c);
CV_Assert( norm(b, c, CV_C) == 0 ); CV_Assert( cvtest::norm(b, c, CV_C) == 0 );
add(Mat::zeros(3, 3, CV_64F), b, c, noArray(), c.type()); add(Mat::zeros(3, 3, CV_64F), b, c, noArray(), c.type());
CV_Assert( norm(b, c, CV_C) == 0 ); CV_Assert( cvtest::norm(b, c, CV_C) == 0 );
add(Mat::zeros(6, 1, CV_64F), 1, c, noArray(), c.type()); add(Mat::zeros(6, 1, CV_64F), 1, c, noArray(), c.type());
CV_Assert( norm(Matx61f(1.f, 1.f, 1.f, 1.f, 1.f, 1.f), c, CV_C) == 0 ); CV_Assert( cvtest::norm(Matx61f(1.f, 1.f, 1.f, 1.f, 1.f, 1.f), c, CV_C) == 0 );
vector<Point2f> pt2d(3); vector<Point2f> pt2d(3);
vector<Point3d> pt3d(2); vector<Point3d> pt3d(2);
@ -1066,11 +1066,11 @@ bool CV_OperationsTest::TestSVD()
Mat A = (Mat_<double>(3,4) << 1, 2, -1, 4, 2, 4, 3, 5, -1, -2, 6, 7); Mat A = (Mat_<double>(3,4) << 1, 2, -1, 4, 2, 4, 3, 5, -1, -2, 6, 7);
Mat x; Mat x;
SVD::solveZ(A,x); SVD::solveZ(A,x);
if( norm(A*x, CV_C) > FLT_EPSILON ) if( cvtest::norm(A*x, CV_C) > FLT_EPSILON )
throw test_excep(); throw test_excep();
SVD svd(A, SVD::FULL_UV); SVD svd(A, SVD::FULL_UV);
if( norm(A*svd.vt.row(3).t(), CV_C) > FLT_EPSILON ) if( cvtest::norm(A*svd.vt.row(3).t(), CV_C) > FLT_EPSILON )
throw test_excep(); throw test_excep();
Mat Dp(3,3,CV_32FC1); Mat Dp(3,3,CV_32FC1);
@ -1094,11 +1094,11 @@ bool CV_OperationsTest::TestSVD()
W=decomp.w; W=decomp.w;
Mat I = Mat::eye(3, 3, CV_32F); Mat I = Mat::eye(3, 3, CV_32F);
if( norm(U*U.t(), I, CV_C) > FLT_EPSILON || if( cvtest::norm(U*U.t(), I, CV_C) > FLT_EPSILON ||
norm(Vt*Vt.t(), I, CV_C) > FLT_EPSILON || cvtest::norm(Vt*Vt.t(), I, CV_C) > FLT_EPSILON ||
W.at<float>(2) < 0 || W.at<float>(1) < W.at<float>(2) || W.at<float>(2) < 0 || W.at<float>(1) < W.at<float>(2) ||
W.at<float>(0) < W.at<float>(1) || W.at<float>(0) < W.at<float>(1) ||
norm(U*Mat::diag(W)*Vt, Q, CV_C) > FLT_EPSILON ) cvtest::norm(U*Mat::diag(W)*Vt, Q, CV_C) > FLT_EPSILON )
throw test_excep(); throw test_excep();
} }
catch(const test_excep&) catch(const test_excep&)

View File

@ -174,7 +174,7 @@ void Core_RandTest::run( int )
} }
} }
if( maxk >= 1 && norm(arr[0], arr[1], NORM_INF) > eps) if( maxk >= 1 && cvtest::norm(arr[0], arr[1], NORM_INF) > eps)
{ {
ts->printf( cvtest::TS::LOG, "RNG output depends on the array lengths (some generated numbers get lost?)" ); ts->printf( cvtest::TS::LOG, "RNG output depends on the array lengths (some generated numbers get lost?)" );
ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT ); ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );

View File

@ -563,12 +563,12 @@ protected:
void checkDiff(const Mat& m1, const Mat& m2, const string& s) void checkDiff(const Mat& m1, const Mat& m2, const string& s)
{ {
if (norm(m1, m2, NORM_INF) != 0) if (cvtest::norm(m1, m2, NORM_INF) != 0)
throw test_excep(s); throw test_excep(s);
} }
void checkDiffF(const Mat& m1, const Mat& m2, const string& s) void checkDiffF(const Mat& m1, const Mat& m2, const string& s)
{ {
if (norm(m1, m2, NORM_INF) > 1e-5) if (cvtest::norm(m1, m2, NORM_INF) > 1e-5)
throw test_excep(s); throw test_excep(s);
} }
}; };
@ -721,7 +721,7 @@ TEST(Core_UMat, getUMat)
um.setTo(17); um.setTo(17);
} }
double err = norm(m, ref, NORM_INF); double err = cvtest::norm(m, ref, NORM_INF);
if (err > 0) if (err > 0)
{ {
std::cout << "m: " << std::endl << m << std::endl; std::cout << "m: " << std::endl << m << std::endl;
@ -742,7 +742,7 @@ TEST(UMat, Sync)
um.setTo(cv::Scalar::all(19)); um.setTo(cv::Scalar::all(19));
EXPECT_EQ(0, cv::norm(um.getMat(ACCESS_READ), cv::Mat(um.size(), um.type(), 19), NORM_INF)); EXPECT_EQ(0, cvtest::norm(um.getMat(ACCESS_READ), cv::Mat(um.size(), um.type(), 19), NORM_INF));
} }
TEST(UMat, setOpenCL) TEST(UMat, setOpenCL)

View File

@ -119,8 +119,8 @@ void CV_FastTest::run( int )
read( fs["exp_kps2"], exp_kps2, Mat() ); read( fs["exp_kps2"], exp_kps2, Mat() );
fs.release(); fs.release();
if ( exp_kps1.size != kps1.size || 0 != norm(exp_kps1, kps1, NORM_L2) || if ( exp_kps1.size != kps1.size || 0 != cvtest::norm(exp_kps1, kps1, NORM_L2) ||
exp_kps2.size != kps2.size || 0 != norm(exp_kps2, kps2, NORM_L2)) exp_kps2.size != kps2.size || 0 != cvtest::norm(exp_kps2, kps2, NORM_L2))
{ {
ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH); ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH);
return; return;

View File

@ -193,8 +193,8 @@ int CV_KDTreeTest_CPP::checkGetPoins( const Mat& data )
// 3d way // 3d way
tr->getPoints( idxs, res3 ); tr->getPoints( idxs, res3 );
if( norm( res1, data, NORM_L1) != 0 || if( cvtest::norm( res1, data, NORM_L1) != 0 ||
norm( res3, data, NORM_L1) != 0) cvtest::norm( res3, data, NORM_L1) != 0)
return cvtest::TS::FAIL_BAD_ACCURACY; return cvtest::TS::FAIL_BAD_ACCURACY;
return cvtest::TS::OK; return cvtest::TS::OK;
} }
@ -232,7 +232,7 @@ int CV_KDTreeTest_CPP::findNeighbors( Mat& points, Mat& neighbors )
} }
// compare results // compare results
if( norm( neighbors, neighbors2, NORM_L1 ) != 0 ) if( cvtest::norm( neighbors, neighbors2, NORM_L1 ) != 0 )
return cvtest::TS::FAIL_BAD_ACCURACY; return cvtest::TS::FAIL_BAD_ACCURACY;
return cvtest::TS::OK; return cvtest::TS::OK;
@ -284,7 +284,7 @@ int CV_FlannTest::knnSearch( Mat& points, Mat& neighbors )
} }
// compare results // compare results
if( norm( neighbors, neighbors1, NORM_L1 ) != 0 ) if( cvtest::norm( neighbors, neighbors1, NORM_L1 ) != 0 )
return cvtest::TS::FAIL_BAD_ACCURACY; return cvtest::TS::FAIL_BAD_ACCURACY;
return cvtest::TS::OK; return cvtest::TS::OK;
@ -316,7 +316,7 @@ int CV_FlannTest::radiusSearch( Mat& points, Mat& neighbors )
neighbors1.at<int>(i,j) = *it; neighbors1.at<int>(i,j) = *it;
} }
// compare results // compare results
if( norm( neighbors, neighbors1, NORM_L1 ) != 0 ) if( cvtest::norm( neighbors, neighbors1, NORM_L1 ) != 0 )
return cvtest::TS::FAIL_BAD_ACCURACY; return cvtest::TS::FAIL_BAD_ACCURACY;
return cvtest::TS::OK; return cvtest::TS::OK;

View File

@ -76,7 +76,7 @@ void CV_DrawingTest::run( int )
} }
else else
{ {
float err = (float)norm( testImg, valImg, CV_RELATIVE_L1 ); float err = (float)cvtest::norm( testImg, valImg, CV_RELATIVE_L1 );
float Eps = 0.9f; float Eps = 0.9f;
if( err > Eps) if( err > Eps)
{ {
@ -229,7 +229,7 @@ int CV_DrawingTest_CPP::checkLineIterator( Mat& img )
for(int i = 0; i < it.count; ++it, i++ ) for(int i = 0; i < it.count; ++it, i++ )
{ {
Vec3b v = (Vec3b)(*(*it)) - img.at<Vec3b>(300,i); Vec3b v = (Vec3b)(*(*it)) - img.at<Vec3b>(300,i);
float err = (float)norm( v ); float err = (float)cvtest::norm( v, NORM_L2 );
if( err != 0 ) if( err != 0 )
{ {
ts->printf( ts->LOG, "LineIterator works incorrect" ); ts->printf( ts->LOG, "LineIterator works incorrect" );
@ -395,7 +395,7 @@ int CV_DrawingTest_C::checkLineIterator( Mat& _img )
for(int i = 0; i < count; i++ ) for(int i = 0; i < count; i++ )
{ {
Vec3b v = (Vec3b)(*(it.ptr)) - _img.at<Vec3b>(300,i); Vec3b v = (Vec3b)(*(it.ptr)) - _img.at<Vec3b>(300,i);
float err = (float)norm( v ); float err = (float)cvtest::norm( v, NORM_L2 );
if( err != 0 ) if( err != 0 )
{ {
ts->printf( ts->LOG, "CvLineIterator works incorrect" ); ts->printf( ts->LOG, "CvLineIterator works incorrect" );

View File

@ -163,7 +163,7 @@ public:
CV_Assert( !img0.empty() && !img.empty() && img_next.empty() ); CV_Assert( !img0.empty() && !img.empty() && img_next.empty() );
double diff = norm(img0, img, CV_C); double diff = cvtest::norm(img0, img, CV_C);
CV_Assert( diff == 0 ); CV_Assert( diff == 0 );
} }
catch(...) catch(...)

View File

@ -121,7 +121,7 @@ public:
CV_Assert(img.type() == img_test.type()); CV_Assert(img.type() == img_test.type());
CV_Assert(num_channels == img_test.channels()); CV_Assert(num_channels == img_test.channels());
double n = norm(img, img_test); double n = cvtest::norm(img, img_test, NORM_L2);
if ( n > 1.0) if ( n > 1.0)
{ {
ts->printf(ts->LOG, "norm = %f \n", n); ts->printf(ts->LOG, "norm = %f \n", n);
@ -151,7 +151,7 @@ public:
CV_Assert(img.size() == img_test.size()); CV_Assert(img.size() == img_test.size());
CV_Assert(img.type() == img_test.type()); CV_Assert(img.type() == img_test.type());
double n = norm(img, img_test); double n = cvtest::norm(img, img_test, NORM_L2);
if ( n > 1.0) if ( n > 1.0)
{ {
ts->printf(ts->LOG, "norm = %f \n", n); ts->printf(ts->LOG, "norm = %f \n", n);
@ -183,7 +183,7 @@ public:
CV_Assert(img.type() == img_test.type()); CV_Assert(img.type() == img_test.type());
double n = norm(img, img_test); double n = cvtest::norm(img, img_test, NORM_L2);
if ( n > 1.0) if ( n > 1.0)
{ {
ts->printf(ts->LOG, "norm = %f \n", n); ts->printf(ts->LOG, "norm = %f \n", n);
@ -210,7 +210,7 @@ public:
{ {
Mat rle = imread(string(ts->get_data_path()) + "readwrite/rle8.bmp"); Mat rle = imread(string(ts->get_data_path()) + "readwrite/rle8.bmp");
Mat bmp = imread(string(ts->get_data_path()) + "readwrite/ordinary.bmp"); Mat bmp = imread(string(ts->get_data_path()) + "readwrite/ordinary.bmp");
if (norm(rle-bmp)>1.e-10) if (cvtest::norm(rle-bmp, NORM_L2)>1.e-10)
ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY); ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
} }
catch(...) catch(...)
@ -406,7 +406,7 @@ TEST(Highgui_Jpeg, encode_decode_progressive_jpeg)
EXPECT_NO_THROW(cv::imwrite(output_normal, img)); EXPECT_NO_THROW(cv::imwrite(output_normal, img));
cv::Mat img_jpg_normal = cv::imread(output_normal); cv::Mat img_jpg_normal = cv::imread(output_normal);
EXPECT_EQ(0, cv::norm(img_jpg_progressive, img_jpg_normal, NORM_INF)); EXPECT_EQ(0, cvtest::norm(img_jpg_progressive, img_jpg_normal, NORM_INF));
remove(output_progressive.c_str()); remove(output_progressive.c_str());
} }
@ -430,7 +430,7 @@ TEST(Highgui_Jpeg, encode_decode_optimize_jpeg)
EXPECT_NO_THROW(cv::imwrite(output_normal, img)); EXPECT_NO_THROW(cv::imwrite(output_normal, img));
cv::Mat img_jpg_normal = cv::imread(output_normal); cv::Mat img_jpg_normal = cv::imread(output_normal);
EXPECT_EQ(0, cv::norm(img_jpg_optimized, img_jpg_normal, NORM_INF)); EXPECT_EQ(0, cvtest::norm(img_jpg_optimized, img_jpg_normal, NORM_INF));
remove(output_optimized.c_str()); remove(output_optimized.c_str());
} }
@ -612,11 +612,11 @@ TEST(Highgui_WebP, encode_decode_lossless_webp)
cv::Mat decode = cv::imdecode(buf, IMREAD_COLOR); cv::Mat decode = cv::imdecode(buf, IMREAD_COLOR);
ASSERT_FALSE(decode.empty()); ASSERT_FALSE(decode.empty());
EXPECT_TRUE(cv::norm(decode, img_webp, NORM_INF) == 0); EXPECT_TRUE(cvtest::norm(decode, img_webp, NORM_INF) == 0);
ASSERT_FALSE(img_webp.empty()); ASSERT_FALSE(img_webp.empty());
EXPECT_TRUE(cv::norm(img, img_webp, NORM_INF) == 0); EXPECT_TRUE(cvtest::norm(img, img_webp, NORM_INF) == 0);
} }
TEST(Highgui_WebP, encode_decode_lossy_webp) TEST(Highgui_WebP, encode_decode_lossy_webp)

View File

@ -264,7 +264,7 @@ namespace cvtest
reference_dst.convertTo(reference_dst, type); reference_dst.convertTo(reference_dst, type);
} }
double e = norm(reference_dst, _parallel_dst); double e = cvtest::norm(reference_dst, _parallel_dst, NORM_L2);
if (e > eps) if (e > eps)
{ {
ts->printf(cvtest::TS::CONSOLE, "actual error: %g, expected: %g", e, eps); ts->printf(cvtest::TS::CONSOLE, "actual error: %g, expected: %g", e, eps);

View File

@ -91,12 +91,12 @@ void CV_ConnectedComponentsTest::run( int /* start_from */)
exp = labelImage; exp = labelImage;
} }
if (0 != norm(labelImage > 0, exp > 0, NORM_INF)) if (0 != cvtest::norm(labelImage > 0, exp > 0, NORM_INF))
{ {
ts->set_failed_test_info( cvtest::TS::FAIL_MISMATCH ); ts->set_failed_test_info( cvtest::TS::FAIL_MISMATCH );
return; return;
} }
if (nLabels != norm(labelImage, NORM_INF)+1) if (nLabels != cvtest::norm(labelImage, NORM_INF)+1)
{ {
ts->set_failed_test_info( cvtest::TS::FAIL_MISMATCH ); ts->set_failed_test_info( cvtest::TS::FAIL_MISMATCH );
return; return;

View File

@ -566,6 +566,8 @@ int CV_ConvHullTest::validate_test_results( int test_case_idx )
hull = cvCreateMat( 1, hull_count, CV_32FC2 ); hull = cvCreateMat( 1, hull_count, CV_32FC2 );
mask = cvCreateMat( 1, hull_count, CV_8UC1 ); mask = cvCreateMat( 1, hull_count, CV_8UC1 );
cvZero( mask ); cvZero( mask );
Mat _mask = cvarrToMat(mask);
h = (CvPoint2D32f*)(hull->data.ptr); h = (CvPoint2D32f*)(hull->data.ptr);
// extract convex hull points // extract convex hull points
@ -643,7 +645,7 @@ int CV_ConvHullTest::validate_test_results( int test_case_idx )
mask->data.ptr[idx] = (uchar)1; mask->data.ptr[idx] = (uchar)1;
} }
if( cvNorm( mask, 0, CV_L1 ) != hull_count ) if( cvtest::norm( _mask, Mat::zeros(_mask.dims, _mask.size, _mask.type()), NORM_L1 ) != hull_count )
{ {
ts->printf( cvtest::TS::LOG, "Not every convex hull vertex coincides with some input point\n" ); ts->printf( cvtest::TS::LOG, "Not every convex hull vertex coincides with some input point\n" );
code = cvtest::TS::FAIL_BAD_ACCURACY; code = cvtest::TS::FAIL_BAD_ACCURACY;

View File

@ -137,7 +137,7 @@ void CV_HoughLinesTest::run_test(int type)
if( exp_lines.size != lines.size ) if( exp_lines.size != lines.size )
transpose(lines, lines); transpose(lines, lines);
if ( exp_lines.size != lines.size || norm(exp_lines, lines, NORM_INF) > 1e-4 ) if ( exp_lines.size != lines.size || cvtest::norm(exp_lines, lines, NORM_INF) > 1e-4 )
{ {
ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH); ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH);
return; return;

View File

@ -1530,7 +1530,7 @@ TEST(Imgproc_resize_area, regression)
} }
} }
ASSERT_EQ(norm(one_channel_diff, cv::NORM_INF), 0); ASSERT_EQ(cvtest::norm(one_channel_diff, cv::NORM_INF), 0);
} }

View File

@ -254,7 +254,7 @@ void CV_ImageWarpBaseTest::validate_results() const
// fabs(rD[dx] - D[dx]) < 250.0f && // fabs(rD[dx] - D[dx]) < 250.0f &&
rD[dx] <= 255.0f && D[dx] <= 255.0f && rD[dx] >= 0.0f && D[dx] >= 0.0f) rD[dx] <= 255.0f && D[dx] <= 255.0f && rD[dx] >= 0.0f && D[dx] >= 0.0f)
{ {
PRINT_TO_LOG("\nNorm of the difference: %lf\n", norm(reference_dst, _dst, NORM_INF)); PRINT_TO_LOG("\nNorm of the difference: %lf\n", cvtest::norm(reference_dst, _dst, NORM_INF));
PRINT_TO_LOG("Error in (dx, dy): (%d, %d)\n", dx / cn + 1, dy + 1); PRINT_TO_LOG("Error in (dx, dy): (%d, %d)\n", dx / cn + 1, dy + 1);
PRINT_TO_LOG("Tuple (rD, D): (%f, %f)\n", rD[dx], D[dx]); PRINT_TO_LOG("Tuple (rD, D): (%f, %f)\n", rD[dx], D[dx]);
PRINT_TO_LOG("Dsize: (%d, %d)\n", dsize.width / cn, dsize.height); PRINT_TO_LOG("Dsize: (%d, %d)\n", dsize.width / cn, dsize.height);

View File

@ -52,7 +52,9 @@ void nbayes_check_data( CvMLData* _data )
CV_Error( CV_StsBadArg, "missing values are not supported" ); CV_Error( CV_StsBadArg, "missing values are not supported" );
const CvMat* var_types = _data->get_var_types(); const CvMat* var_types = _data->get_var_types();
bool is_classifier = var_types->data.ptr[var_types->cols-1] == CV_VAR_CATEGORICAL; bool is_classifier = var_types->data.ptr[var_types->cols-1] == CV_VAR_CATEGORICAL;
if( ( fabs( cvNorm( var_types, 0, CV_L1 ) -
Mat _var_types = cvarrToMat(var_types);
if( ( fabs( cvtest::norm( _var_types, Mat::zeros(_var_types.dims, _var_types.size, _var_types.type()), CV_L1 ) -
(var_types->rows + var_types->cols - 2)*CV_VAR_ORDERED - CV_VAR_CATEGORICAL ) > FLT_EPSILON ) || (var_types->rows + var_types->cols - 2)*CV_VAR_ORDERED - CV_VAR_CATEGORICAL ) > FLT_EPSILON ) ||
!is_classifier ) !is_classifier )
CV_Error( CV_StsBadArg, "incorrect types of predictors or responses" ); CV_Error( CV_StsBadArg, "incorrect types of predictors or responses" );

View File

@ -184,8 +184,8 @@ TEST(DISABLED_ML_SVM, linear_save_load)
svm3.predict(samples, r3); svm3.predict(samples, r3);
double eps = 1e-4; double eps = 1e-4;
EXPECT_LE(norm(r1, r2, NORM_INF), eps); EXPECT_LE(cvtest::norm(r1, r2, NORM_INF), eps);
EXPECT_LE(norm(r1, r3, NORM_INF), eps); EXPECT_LE(cvtest::norm(r1, r3, NORM_INF), eps);
remove(tname.c_str()); remove(tname.c_str());
} }

View File

@ -1087,7 +1087,7 @@ void HOGDescriptorTester::detect(const Mat& img,
} }
const double eps = 0.0; const double eps = 0.0;
double diff_norm = norm(Mat(actual_weights) - Mat(weights), NORM_L2); double diff_norm = cvtest::norm(actual_weights, weights, NORM_L2);
if (diff_norm > eps) if (diff_norm > eps)
{ {
ts->printf(cvtest::TS::SUMMARY, "Weights for found locations aren't equal.\n" ts->printf(cvtest::TS::SUMMARY, "Weights for found locations aren't equal.\n"
@ -1168,7 +1168,7 @@ void HOGDescriptorTester::compute(InputArray _img, vector<float>& descriptors,
std::vector<float> actual_descriptors; std::vector<float> actual_descriptors;
actual_hog->compute(img, actual_descriptors, winStride, padding, locations); actual_hog->compute(img, actual_descriptors, winStride, padding, locations);
double diff_norm = cv::norm(Mat(actual_descriptors) - Mat(descriptors), NORM_L2); double diff_norm = cvtest::norm(actual_descriptors, descriptors, NORM_L2);
const double eps = 0.0; const double eps = 0.0;
if (diff_norm > eps) if (diff_norm > eps)
{ {
@ -1318,7 +1318,7 @@ void HOGDescriptorTester::computeGradient(const Mat& img, Mat& grad, Mat& qangle
const double eps = 0.0; const double eps = 0.0;
for (i = 0; i < 2; ++i) for (i = 0; i < 2; ++i)
{ {
double diff_norm = norm(reference_mats[i] - actual_mats[i], NORM_L2); double diff_norm = cvtest::norm(reference_mats[i], actual_mats[i], NORM_L2);
if (diff_norm > eps) if (diff_norm > eps)
{ {
ts->printf(cvtest::TS::LOG, "%s matrices are not equal\n" ts->printf(cvtest::TS::LOG, "%s matrices are not equal\n"

View File

@ -47,6 +47,8 @@ using cv::Scalar;
using cv::Size; using cv::Size;
using cv::Point; using cv::Point;
using cv::Rect; using cv::Rect;
using cv::InputArray;
using cv::noArray;
class CV_EXPORTS TS; class CV_EXPORTS TS;
@ -124,8 +126,8 @@ CV_EXPORTS void initUndistortMap( const Mat& a, const Mat& k, Size sz, Mat& mapx
CV_EXPORTS void minMaxLoc(const Mat& src, double* minval, double* maxval, CV_EXPORTS void minMaxLoc(const Mat& src, double* minval, double* maxval,
vector<int>* minloc, vector<int>* maxloc, const Mat& mask=Mat()); vector<int>* minloc, vector<int>* maxloc, const Mat& mask=Mat());
CV_EXPORTS double norm(const Mat& src, int normType, const Mat& mask=Mat()); CV_EXPORTS double norm(InputArray src, int normType, InputArray mask=noArray());
CV_EXPORTS double norm(const Mat& src1, const Mat& src2, int normType, const Mat& mask=Mat()); CV_EXPORTS double norm(InputArray src1, InputArray src2, int normType, InputArray mask=noArray());
CV_EXPORTS Scalar mean(const Mat& src, const Mat& mask=Mat()); CV_EXPORTS Scalar mean(const Mat& src, const Mat& mask=Mat());
CV_EXPORTS bool cmpUlps(const Mat& data, const Mat& refdata, int expMaxDiff, double* realMaxDiff, vector<int>* idx); CV_EXPORTS bool cmpUlps(const Mat& data, const Mat& refdata, int expMaxDiff, double* realMaxDiff, vector<int>* idx);

View File

@ -243,9 +243,9 @@ struct CV_EXPORTS TestUtils
static inline double checkNormRelative(InputArray m1, InputArray m2, InputArray mask = noArray()) static inline double checkNormRelative(InputArray m1, InputArray m2, InputArray mask = noArray())
{ {
return cv::norm(m1.getMat(), m2.getMat(), cv::NORM_INF, mask) / return cvtest::norm(m1.getMat(), m2.getMat(), cv::NORM_INF, mask) /
std::max((double)std::numeric_limits<float>::epsilon(), std::max((double)std::numeric_limits<float>::epsilon(),
(double)std::max(cv::norm(m1.getMat(), cv::NORM_INF), norm(m2.getMat(), cv::NORM_INF))); (double)std::max(cvtest::norm(m1.getMat(), cv::NORM_INF), cvtest::norm(m2.getMat(), cv::NORM_INF)));
} }
}; };

View File

@ -225,12 +225,12 @@ Mat TestUtils::readImageType(const String &fname, int type)
double TestUtils::checkNorm1(InputArray m, InputArray mask) double TestUtils::checkNorm1(InputArray m, InputArray mask)
{ {
return norm(m.getMat(), NORM_INF, mask); return cvtest::norm(m.getMat(), NORM_INF, mask.getMat());
} }
double TestUtils::checkNorm2(InputArray m1, InputArray m2, InputArray mask) double TestUtils::checkNorm2(InputArray m1, InputArray m2, InputArray mask)
{ {
return norm(m1.getMat(), m2.getMat(), NORM_INF, mask); return cvtest::norm(m1.getMat(), m2.getMat(), NORM_INF, mask.getMat());
} }
double TestUtils::checkSimilarity(InputArray m1, InputArray m2) double TestUtils::checkSimilarity(InputArray m1, InputArray m2)

View File

@ -1238,15 +1238,16 @@ norm_(const _Tp* src1, const _Tp* src2, size_t total, int cn, int normType, doub
} }
double norm(const Mat& src, int normType, const Mat& mask) double norm(InputArray _src, int normType, InputArray _mask)
{ {
Mat src = _src.getMat(), mask = _mask.getMat();
if( normType == NORM_HAMMING || normType == NORM_HAMMING2 ) if( normType == NORM_HAMMING || normType == NORM_HAMMING2 )
{ {
if( !mask.empty() ) if( !mask.empty() )
{ {
Mat temp; Mat temp;
bitwise_and(src, mask, temp); bitwise_and(src, mask, temp);
return norm(temp, normType, Mat()); return cvtest::norm(temp, normType, Mat());
} }
CV_Assert( src.depth() == CV_8U ); CV_Assert( src.depth() == CV_8U );
@ -1317,8 +1318,12 @@ double norm(const Mat& src, int normType, const Mat& mask)
} }
double norm(const Mat& src1, const Mat& src2, int normType, const Mat& mask) double norm(InputArray _src1, InputArray _src2, int normType, InputArray _mask)
{ {
Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat();
bool isRelative = (normType & NORM_RELATIVE) != 0;
normType &= ~NORM_RELATIVE;
if( normType == NORM_HAMMING || normType == NORM_HAMMING2 ) if( normType == NORM_HAMMING || normType == NORM_HAMMING2 )
{ {
Mat temp; Mat temp;
@ -1391,7 +1396,7 @@ double norm(const Mat& src1, const Mat& src2, int normType, const Mat& mask)
} }
if( normType0 == NORM_L2 ) if( normType0 == NORM_L2 )
result = sqrt(result); result = sqrt(result);
return result; return isRelative ? result / (cvtest::norm(src2, normType) + DBL_EPSILON) : result;
} }