提交 7cd4edd6 编写于 作者: A Andrey Kamaev 提交者: OpenCV Buildbot

Merge pull request #518 from asmorkalov:ts_refactor

......@@ -296,37 +296,15 @@ int ArrayTest::validate_test_results( int test_case_idx )
for( j = 0; j < sizei; j++ )
{
double err_level;
vector<int> idx;
double max_diff = 0;
int code;
char msg[100];
if( !test_array[i1][j] )
continue;
err_level = get_success_error_level( test_case_idx, i0, (int)j );
code = cmpEps( test_mat[i0][j], test_mat[i1][j], &max_diff, err_level, &idx, element_wise_relative_error );
code = cmpEps2(ts, test_mat[i0][j], test_mat[i1][j], err_level, element_wise_relative_error, arr_names[i0]);
switch( code )
{
case -1:
sprintf( msg, "Too big difference (=%g)", max_diff );
code = TS::FAIL_BAD_ACCURACY;
break;
case -2:
strcpy( msg, "Invalid output" );
code = TS::FAIL_INVALID_OUTPUT;
break;
case -3:
strcpy( msg, "Invalid output in the reference array" );
code = TS::FAIL_INVALID_OUTPUT;
break;
default:
continue;
}
string idxstr = vec2str(", ", &idx[0], idx.size());
ts->printf( TS::LOG, "%s in %s array %d at (%s)", msg, arr_names[i0], j, idxstr.c_str() );
if (code == 0) continue;
for( i0 = 0; i0 < (int)test_array.size(); i0++ )
{
......
......@@ -1934,6 +1934,10 @@ int check( const Mat& a, double fmin, double fmax, vector<int>* _idx )
return idx == 0 ? 0 : -1;
}
#define CMP_EPS_OK 0
#define CMP_EPS_BIG_DIFF -1
#define CMP_EPS_INVALID_TEST_DATA -2 // there is NaN or Inf value in test data
#define CMP_EPS_INVALID_REF_DATA -3 // there is NaN or Inf value in reference data
// compares two arrays. max_diff is the maximum actual difference,
// success_err_level is maximum allowed difference, idx is the index of the first
......@@ -1946,7 +1950,7 @@ int cmpEps( const Mat& arr, const Mat& refarr, double* _realmaxdiff,
CV_Assert( arr.type() == refarr.type() && arr.size == refarr.size );
int ilevel = refarr.depth() <= CV_32S ? cvFloor(success_err_level) : 0;
int result = 0;
int result = CMP_EPS_OK;
const Mat *arrays[]={&arr, &refarr, 0};
Mat planes[2];
......@@ -1998,13 +2002,13 @@ int cmpEps( const Mat& arr, const Mat& refarr, double* _realmaxdiff,
continue;
if( cvIsNaN(a_val) || cvIsInf(a_val) )
{
result = -2;
result = CMP_EPS_INVALID_TEST_DATA;
idx = startidx + j;
break;
}
if( cvIsNaN(b_val) || cvIsInf(b_val) )
{
result = -3;
result = CMP_EPS_INVALID_REF_DATA;
idx = startidx + j;
break;
}
......@@ -2029,13 +2033,13 @@ int cmpEps( const Mat& arr, const Mat& refarr, double* _realmaxdiff,
continue;
if( cvIsNaN(a_val) || cvIsInf(a_val) )
{
result = -2;
result = CMP_EPS_INVALID_TEST_DATA;
idx = startidx + j;
break;
}
if( cvIsNaN(b_val) || cvIsInf(b_val) )
{
result = -3;
result = CMP_EPS_INVALID_REF_DATA;
idx = startidx + j;
break;
}
......@@ -2051,7 +2055,7 @@ int cmpEps( const Mat& arr, const Mat& refarr, double* _realmaxdiff,
break;
default:
assert(0);
return -1;
return CMP_EPS_BIG_DIFF;
}
if(_realmaxdiff)
*_realmaxdiff = MAX(*_realmaxdiff, realmaxdiff);
......@@ -2060,7 +2064,7 @@ int cmpEps( const Mat& arr, const Mat& refarr, double* _realmaxdiff,
}
if( result == 0 && idx != 0 )
result = -1;
result = CMP_EPS_BIG_DIFF;
if( result < -1 && _realmaxdiff )
*_realmaxdiff = exp(1000.);
......@@ -2081,15 +2085,15 @@ int cmpEps2( TS* ts, const Mat& a, const Mat& b, double success_err_level,
switch( code )
{
case -1:
case CMP_EPS_BIG_DIFF:
sprintf( msg, "%s: Too big difference (=%g)", desc, diff );
code = TS::FAIL_BAD_ACCURACY;
break;
case -2:
case CMP_EPS_INVALID_TEST_DATA:
sprintf( msg, "%s: Invalid output", desc );
code = TS::FAIL_INVALID_OUTPUT;
break;
case -3:
case CMP_EPS_INVALID_REF_DATA:
sprintf( msg, "%s: Invalid reference output", desc );
code = TS::FAIL_INVALID_OUTPUT;
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册