|
|
|
@ -75,6 +75,11 @@ void testReduce( const Mat& src, Mat& sum, Mat& avg, Mat& max, Mat& min, int dim |
|
|
|
|
sum.setTo(Scalar(0)); |
|
|
|
|
max.setTo(Scalar(-DBL_MAX)); |
|
|
|
|
min.setTo(Scalar(DBL_MAX)); |
|
|
|
|
|
|
|
|
|
const Mat_<Type>& src_ = src; |
|
|
|
|
Mat_<double>& sum_ = (Mat_<double>&)sum; |
|
|
|
|
Mat_<double>& min_ = (Mat_<double>&)min; |
|
|
|
|
Mat_<double>& max_ = (Mat_<double>&)max; |
|
|
|
|
|
|
|
|
|
if( dim == 0 ) |
|
|
|
|
{ |
|
|
|
@ -82,9 +87,9 @@ void testReduce( const Mat& src, Mat& sum, Mat& avg, Mat& max, Mat& min, int dim |
|
|
|
|
{ |
|
|
|
|
for( int ci = 0; ci < src.cols; ci++ ) |
|
|
|
|
{ |
|
|
|
|
sum.at<double>(0, ci) += src.at<Type>(ri, ci); |
|
|
|
|
max.at<double>(0, ci) = std::max( max.at<double>(0, ci), (double)src.at<Type>(ri, ci) ); |
|
|
|
|
min.at<double>(0, ci) = std::min( min.at<double>(0, ci), (double)src.at<Type>(ri, ci) ); |
|
|
|
|
sum_(0, ci) += src_(ri, ci); |
|
|
|
|
max_(0, ci) = std::max( max_(0, ci), (double)src_(ri, ci) ); |
|
|
|
|
min_(0, ci) = std::min( min_(0, ci), (double)src_(ri, ci) ); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -94,9 +99,9 @@ void testReduce( const Mat& src, Mat& sum, Mat& avg, Mat& max, Mat& min, int dim |
|
|
|
|
{ |
|
|
|
|
for( int ri = 0; ri < src.rows; ri++ ) |
|
|
|
|
{ |
|
|
|
|
sum.at<double>(ri, 0) += src.at<Type>(ri, ci); |
|
|
|
|
max.at<double>(ri, 0) = std::max( max.at<double>(ri, 0), (double)src.at<Type>(ri, ci) ); |
|
|
|
|
min.at<double>(ri, 0) = std::min( min.at<double>(ri, 0), (double)src.at<Type>(ri, ci) ); |
|
|
|
|
sum_(ri, 0) += src_(ri, ci); |
|
|
|
|
max_(ri, 0) = std::max( max_(ri, 0), (double)src_(ri, ci) ); |
|
|
|
|
min_(ri, 0) = std::min( min_(ri, 0), (double)src_(ri, ci) ); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -119,37 +124,37 @@ int CV_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat& |
|
|
|
|
{ |
|
|
|
|
int srcType = src.type(); |
|
|
|
|
bool support = false; |
|
|
|
|
if( opType == CV_REDUCE_SUM || opType == CV_REDUCE_AVG ) |
|
|
|
|
{ |
|
|
|
|
if( srcType == CV_8U && (dstType == CV_32S || dstType == CV_32F || dstType == CV_64F) ) |
|
|
|
|
support = true; |
|
|
|
|
if( srcType == CV_16U && (dstType == CV_32F || dstType == CV_64F) ) |
|
|
|
|
support = true; |
|
|
|
|
if( srcType == CV_16S && (dstType == CV_32F || dstType == CV_64F) ) |
|
|
|
|
support = true; |
|
|
|
|
if( srcType == CV_32F && (dstType == CV_32F || dstType == CV_64F) ) |
|
|
|
|
support = true; |
|
|
|
|
if( srcType == CV_64F && dstType == CV_64F) |
|
|
|
|
support = true; |
|
|
|
|
} |
|
|
|
|
else if( opType == CV_REDUCE_MAX ) |
|
|
|
|
{ |
|
|
|
|
if( srcType == CV_8U && dstType == CV_8U ) |
|
|
|
|
support = true; |
|
|
|
|
if( srcType == CV_32F && dstType == CV_32F ) |
|
|
|
|
support = true; |
|
|
|
|
if( srcType == CV_64F && dstType == CV_64F ) |
|
|
|
|
support = true; |
|
|
|
|
} |
|
|
|
|
else if( opType == CV_REDUCE_MIN ) |
|
|
|
|
{ |
|
|
|
|
if( srcType == CV_8U && dstType == CV_8U) |
|
|
|
|
support = true; |
|
|
|
|
if( srcType == CV_32F && dstType == CV_32F) |
|
|
|
|
support = true; |
|
|
|
|
if( srcType == CV_64F && dstType == CV_64F) |
|
|
|
|
support = true; |
|
|
|
|
} |
|
|
|
|
if( opType == CV_REDUCE_SUM || opType == CV_REDUCE_AVG ) |
|
|
|
|
{ |
|
|
|
|
if( srcType == CV_8U && (dstType == CV_32S || dstType == CV_32F || dstType == CV_64F) ) |
|
|
|
|
support = true; |
|
|
|
|
if( srcType == CV_16U && (dstType == CV_32F || dstType == CV_64F) ) |
|
|
|
|
support = true; |
|
|
|
|
if( srcType == CV_16S && (dstType == CV_32F || dstType == CV_64F) ) |
|
|
|
|
support = true; |
|
|
|
|
if( srcType == CV_32F && (dstType == CV_32F || dstType == CV_64F) ) |
|
|
|
|
support = true; |
|
|
|
|
if( srcType == CV_64F && dstType == CV_64F) |
|
|
|
|
support = true; |
|
|
|
|
} |
|
|
|
|
else if( opType == CV_REDUCE_MAX ) |
|
|
|
|
{ |
|
|
|
|
if( srcType == CV_8U && dstType == CV_8U ) |
|
|
|
|
support = true; |
|
|
|
|
if( srcType == CV_32F && dstType == CV_32F ) |
|
|
|
|
support = true; |
|
|
|
|
if( srcType == CV_64F && dstType == CV_64F ) |
|
|
|
|
support = true; |
|
|
|
|
} |
|
|
|
|
else if( opType == CV_REDUCE_MIN ) |
|
|
|
|
{ |
|
|
|
|
if( srcType == CV_8U && dstType == CV_8U) |
|
|
|
|
support = true; |
|
|
|
|
if( srcType == CV_32F && dstType == CV_32F) |
|
|
|
|
support = true; |
|
|
|
|
if( srcType == CV_64F && dstType == CV_64F) |
|
|
|
|
support = true; |
|
|
|
|
} |
|
|
|
|
if( !support ) |
|
|
|
|
return CvTS::OK; |
|
|
|
|
|
|
|
|
@ -158,7 +163,7 @@ int CV_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat& |
|
|
|
|
reduce( src, _dst, dim, opType, dstType ); |
|
|
|
|
_dst.convertTo( dst, CV_64FC1 ); |
|
|
|
|
if( norm( opRes, dst, NORM_INF ) > eps ) |
|
|
|
|
{ |
|
|
|
|
{ |
|
|
|
|
char msg[100]; |
|
|
|
|
const char* opTypeStr = opType == CV_REDUCE_SUM ? "CV_REDUCE_SUM" : |
|
|
|
|
opType == CV_REDUCE_AVG ? "CV_REDUCE_AVG" : |
|
|
|
@ -168,11 +173,11 @@ int CV_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat& |
|
|
|
|
getMatTypeStr( src.type(), srcTypeStr ); |
|
|
|
|
getMatTypeStr( dstType, dstTypeStr ); |
|
|
|
|
const char* dimStr = dim == 0 ? "ROWS" : "COLS"; |
|
|
|
|
|
|
|
|
|
sprintf( msg, "bad accuracy with srcType = %s, dstType = %s, opType = %s, dim = %s", |
|
|
|
|
srcTypeStr.c_str(), dstTypeStr.c_str(), opTypeStr, dimStr ); |
|
|
|
|
ts->printf( CvTS::LOG, msg ); |
|
|
|
|
return CvTS::FAIL_BAD_ACCURACY; |
|
|
|
|
|
|
|
|
|
sprintf( msg, "bad accuracy with srcType = %s, dstType = %s, opType = %s, dim = %s", |
|
|
|
|
srcTypeStr.c_str(), dstTypeStr.c_str(), opTypeStr, dimStr ); |
|
|
|
|
ts->printf( CvTS::LOG, msg ); |
|
|
|
|
return CvTS::FAIL_BAD_ACCURACY; |
|
|
|
|
} |
|
|
|
|
return CvTS::OK; |
|
|
|
|
} |
|
|
|
|