int cn = cvTsRandInt(rng) % 4 + 1;
int i, j;
CvArrTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
+ generate_scalars( depth );
depth += depth == CV_8S;
for( i = 0; i < max_arr; i++ )
double CxCore_AddWeightedTest::get_success_error_level( int test_case_idx, int i, int j )
{
- if( CV_MAT_DEPTH(cvGetElemType(test_array[i][j])) <= CV_32S )
+ int type = cvGetElemType(test_array[i][j]), depth = CV_MAT_DEPTH(type);
+ if( depth <= CV_32S )
+ return 2;
+ if( depth == CV_32F )
{
- return alpha.val[0] != cvRound(alpha.val[0]) ||
- beta.val[0] != cvRound(beta.val[0]) ||
- gamma.val[0] != cvRound(gamma.val[0]);
+ CvScalar low=cvScalarAll(0), high=low;
+ get_minmax_bounds(i,j,type, &low, &high);
+ double a = (fabs(alpha.val[0])+fabs(beta.val[0]))*(fabs(low.val[0])+fabs(high.val[0]));
+ double b = fabs(gamma.val[0]);
+ return (a+b)*500*FLT_EPSILON;
}
- else
- return CvArrTest::get_success_error_level( test_case_idx, i, j );
+ return CvArrTest::get_success_error_level( test_case_idx, i, j );
}
}
-double CxCore_CvtBaseTestImpl::get_success_error_level( int test_case_idx, int i, int j )
+double CxCore_CvtBaseTestImpl::get_success_error_level( int, int, int )
{
- if( CV_MAT_DEPTH(cvGetElemType(test_array[i][j])) <= CV_32S )
- {
+ if( CV_MAT_DEPTH(test_mat[OUTPUT][0].type) <= CV_32S )
return alpha.val[0] != cvRound(alpha.val[0]) ||
beta.val[0] != cvRound(beta.val[0]) ||
gamma.val[0] != cvRound(gamma.val[0]);
+
+ CvScalar l1, h1, l2, h2;
+ int stype = CV_MAT_TYPE(test_mat[INPUT][0].type);
+ int dtype = CV_MAT_TYPE(test_mat[OUTPUT][0].type);
+ get_minmax_bounds( INPUT, 0, stype, &l1, &h1 );
+ get_minmax_bounds( OUTPUT, 0, dtype, &l2, &h2 );
+ double maxval = 0;
+ for( int i = 0; i < 4; i++ )
+ {
+ maxval = MAX(maxval, fabs(l1.val[i]));
+ maxval = MAX(maxval, fabs(h1.val[i]));
+ maxval = MAX(maxval, fabs(l2.val[i]));
+ maxval = MAX(maxval, fabs(h2.val[i]));
}
- else
- return CvArrTest::get_success_error_level( test_case_idx, i, j );
+ double max_err = (CV_MAT_DEPTH(stype) == CV_64F || CV_MAT_DEPTH(dtype) == CV_64F ?
+ DBL_EPSILON : FLT_EPSILON)*maxval*MAX(fabs(alpha.val[0]), 1.)*100;
+ return max_err;
}
{
CxCore_MathTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
out_type = types[OUTPUT][0];
- if( CV_MAT_DEPTH(types[INPUT][0]) == CV_32F && (cvRandInt(ts->get_rng()) & 3) == 0 )
+ /*if( CV_MAT_DEPTH(types[INPUT][0]) == CV_32F && (cvRandInt(ts->get_rng()) & 3) == 0 )
types[OUTPUT][0] = types[REF_OUTPUT][0] =
- out_type = (types[INPUT][0] & ~CV_MAT_DEPTH_MASK)|CV_64F;
+ out_type = (types[INPUT][0] & ~CV_MAT_DEPTH_MASK)|CV_64F;*/
}
void CxCore_ExpTest::get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, CvScalar* low, CvScalar* high )
void CxCore_LogTest::get_test_array_types_and_sizes( int test_case_idx, CvSize** sizes, int** types )
{
CxCore_MathTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
- if( CV_MAT_DEPTH(types[INPUT][0]) == CV_32F && (cvRandInt(ts->get_rng()) & 3) == 0 )
- types[INPUT][0] = (types[INPUT][0] & ~CV_MAT_DEPTH_MASK)|CV_64F;
+ /*if( CV_MAT_DEPTH(types[INPUT][0]) == CV_32F && (cvRandInt(ts->get_rng()) & 3) == 0 )
+ types[INPUT][0] = (types[INPUT][0] & ~CV_MAT_DEPTH_MASK)|CV_64F;*/
}
};
CxCore_ScaleAddTest::CxCore_ScaleAddTest() :
- CxCore_MatrixTest( "matrix-scaleadd", "cvScaleAdd", 3, 1, false, false, 2 )
+ CxCore_MatrixTest( "matrix-scaleadd", "cvScaleAdd", 3, 1, false, false, 4 )
{
alpha = cvScalarAll(0);
}
{
CxCore_MatrixTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
sizes[INPUT][2] = cvSize(1,1);
+ types[INPUT][2] &= CV_MAT_DEPTH_MASK;
}
CxCore_MatrixTest::get_timing_test_array_types_and_sizes( test_case_idx, sizes, types,
whole_sizes, are_images );
sizes[INPUT][2] = cvSize(1,1);
+ types[INPUT][2] &= CV_MAT_DEPTH_MASK;
}
void CxCore_ScaleAddTest::prepare_to_validation( int )
{
- int rows = test_mat[INPUT][0].rows;
- int type = CV_MAT_TYPE(test_mat[INPUT][0].type);
- int cn = CV_MAT_CN(type);
- int ncols = test_mat[INPUT][0].cols*cn;
- int i, j;
-
- for( i = 0; i < rows; i++ )
- {
- uchar* src1 = test_mat[INPUT][0].data.ptr + test_mat[INPUT][0].step*i;
- uchar* src2 = test_mat[INPUT][1].data.ptr + test_mat[INPUT][1].step*i;
- uchar* dst = test_mat[REF_OUTPUT][0].data.ptr + test_mat[REF_OUTPUT][0].step*i;
-
- switch( type )
- {
- case CV_32FC1:
- for( j = 0; j < ncols; j++ )
- ((float*)dst)[j] = (float)(((float*)src1)[j]*alpha.val[0] + ((float*)src2)[j]);
- break;
- case CV_32FC2:
- for( j = 0; j < ncols; j += 2 )
- {
- double re = ((float*)src1)[j];
- double im = ((float*)src1)[j+1];
- ((float*)dst)[j] = (float)(re*alpha.val[0] - im*alpha.val[1] + ((float*)src2)[j]);
- ((float*)dst)[j+1] = (float)(re*alpha.val[1] + im*alpha.val[0] + ((float*)src2)[j+1]);
- }
- break;
- case CV_64FC1:
- for( j = 0; j < ncols; j++ )
- ((double*)dst)[j] = ((double*)src1)[j]*alpha.val[0] + ((double*)src2)[j];
- break;
- case CV_64FC2:
- for( j = 0; j < ncols; j += 2 )
- {
- double re = ((double*)src1)[j];
- double im = ((double*)src1)[j+1];
- ((double*)dst)[j] = (double)(re*alpha.val[0] - im*alpha.val[1] + ((double*)src2)[j]);
- ((double*)dst)[j+1] = (double)(re*alpha.val[1] + im*alpha.val[0] + ((double*)src2)[j+1]);
- }
- break;
- default:
- assert(0);
- }
- }
+ cvTsAdd( &test_mat[INPUT][0], cvScalarAll(alpha.val[0]),
+ &test_mat[INPUT][1], cvScalarAll(1.),
+ cvScalarAll(0.), &test_mat[REF_OUTPUT][0], 0 );
}
CxCore_ScaleAddTest scaleadd_test;
};
CxCore_GEMMTest::CxCore_GEMMTest() :
- CxCore_MatrixTest( "matrix-gemm", "cvGEMM", 5, 1, false, false, 2 )
+ CxCore_MatrixTest( "matrix-gemm", "cvGEMM", 5, 1, false, false, 1 )
{
test_case_count = 100;
default_timing_param_names = matrix_gemm_param_names;
void get_timing_test_array_types_and_sizes( int test_case_idx,
CvSize** sizes, int** types,
CvSize** whole_sizes, bool* are_images );
+ int prepare_test_case( int test_case_idx );
void print_timing_params( int test_case_idx, char* ptr, int params_left );
void run_func();
void prepare_to_validation( int test_case_idx );
+
+ double scale;
};
mattype = depth < CV_32S ? CV_32F : depth == CV_64F ? CV_64F : bits & 1 ? CV_32F : CV_64F;
types[INPUT][1] = mattype;
types[INPUT][2] = CV_MAKETYPE(mattype, dst_cn);
+
+ scale = 1./((cvTsRandInt(rng)%4)*50+1);
if( bits & 2 )
{
sizes[INPUT][1] = cvSize(cn + (cn < 4), cn);
sizes[INPUT][2] = cvSize(0,0);
types[INPUT][1] = types[INPUT][2] = CV_64FC1;
+ scale = 1./1000;
}
+int CxCore_TransformTest::prepare_test_case( int test_case_idx )
+{
+ int code = CxCore_MatrixTest::prepare_test_case( test_case_idx );
+ if( code > 0 )
+ cvTsAdd(&test_mat[INPUT][1], cvScalarAll(scale), &test_mat[INPUT][1],
+ cvScalarAll(0), cvScalarAll(0), &test_mat[INPUT][1], 0 );
+ return code;
+}
void CxCore_TransformTest::print_timing_params( int test_case_idx, char* ptr, int params_left )
{
single_matrix = flags & CV_COVAR_ROWS;
t_flag = (bits & 256) != 0;
+ const int min_count = 2;
+
if( !t_flag )
- len = sizes[INPUT][0].width, count = sizes[INPUT][0].height;
+ {
+ len = sizes[INPUT][0].width;
+ count = sizes[INPUT][0].height;
+ count = std::max(count, min_count);
+ sizes[INPUT][0] = cvSize(len, count);
+ }
else
- len = sizes[INPUT][0].height, count = sizes[INPUT][0].width;
+ {
+ len = sizes[INPUT][0].height;
+ count = sizes[INPUT][0].width;
+ count = std::max(count, min_count);
+ sizes[INPUT][0] = cvSize(count, len);
+ }
if( single_matrix && t_flag )
flags = (flags & ~CV_COVAR_ROWS) | CV_COVAR_COLS;
{
CvMat* input = &test_mat[INPUT][0];
double det = method != CV_LU ? cvTsSVDet( input ) : 0;
- double threshold = (CV_MAT_DEPTH(input->type) == CV_32F ? FLT_EPSILON : DBL_EPSILON)*100;
+ double threshold = (CV_MAT_DEPTH(input->type) == CV_32F ? FLT_EPSILON : DBL_EPSILON)*500;
if( CV_MAT_TYPE(input->type) == CV_32FC1 )
cvTsConvert( input, &test_mat[TEMP][1] );
progress = t;
}
}
- else if( cvRound(dt*0.001) > progress )
+ else if( cvRound(dt) > progress )
{
ts->printf( CvTS::CONSOLE, "." );
- progress = cvRound(dt*0.001);
+ progress = cvRound(dt);
}
return progress;
params.test_mode = CORRECTNESS_CHECK_MODE;
params.timing_mode = MIN_TIME;
params.use_optimized = -1;
+ params.color_terminal = 1;
if( memory_manager )
memory_manager->clear_and_check();
delete selected_tests;
delete failed_tests;
- cvSetMemoryManager( 0, 0 );
}
list_tests = 1;
else if( strcmp( argv[i], "-d" ) == 0 )
set_data_path(argv[++i]);
+ else if( strcmp( argv[i], "-nc" ) == 0 )
+ params.color_terminal = 0;
}
if( write_params )
if( !params.print_only_failed )
{
printf( SUMMARY + CONSOLE, "\t" );
- change_color( CV_TS_GREEN );
+ set_color( CV_TS_GREEN );
printf( SUMMARY + CONSOLE, "Ok\n" );
- change_color( CV_TS_NORMAL );
+ set_color( CV_TS_NORMAL );
}
}
else
{
printf( SUMMARY + CONSOLE, "\t" );
- change_color( CV_TS_RED );
+ set_color( CV_TS_RED );
printf( SUMMARY + CONSOLE, "FAIL(%s)\n", str_from_code(code) );
- change_color( CV_TS_NORMAL );
+ set_color( CV_TS_NORMAL );
printf( LOG, "context: test case = %d, seed = %08x%08x\n",
current_test_info.test_case_idx,
(unsigned)(current_test_info.rng_seed>>32),
"-f - use parameters from the provided config XML/YAML file instead of the default parameters\n\n"
"-h or --help - print this help information\n\n"
"-l - list all the registered tests or subset of the tests, selected in the config file, and exit\n\n"
+ "-nc - do not use colors in the console output\n\n"
"-O{0|1} - disable/enable on-fly detection of IPP and other supported optimized libs. It's enabled by default\n\n"
"-t - switch to the performance testing mode instead of the default algorithmic/correctness testing mode\n\n"
"-w - write default parameters of the algorithmic or performance (when -t is passed) tests to the specifed config file (see -f) and exit\n\n"
}
}
+void CvTS::set_color(int color)
+{
+ if( params.color_terminal )
+ change_color(color);
+}
static char* cv_strnstr( const char* str, int len,
const char* pattern,