]> rtime.felk.cvut.cz Git - opencv.git/commitdiff
round scalars in the case of integer arrays in adds, subrs and absdiffs tests (will...
authorvp153 <vp153@73c94f0f-984f-4a5f-82bc-2d8db8d8ee08>
Mon, 5 Apr 2010 09:40:33 +0000 (09:40 +0000)
committervp153 <vp153@73c94f0f-984f-4a5f-82bc-2d8db8d8ee08>
Mon, 5 Apr 2010 09:40:33 +0000 (09:40 +0000)
git-svn-id: https://code.ros.org/svn/opencv/trunk@2981 73c94f0f-984f-4a5f-82bc-2d8db8d8ee08

opencv/tests/cxcore/src/aarithm.cpp
opencv/tests/cxts/cxts.cpp
opencv/tests/cxts/cxts.h

index ab77f83898313345d531ed50591944145627968d..844a46bcb368fdcd7b3b332c24665c2fe05b1dff 100644 (file)
@@ -65,6 +65,7 @@ protected:
     void get_timing_test_array_types_and_sizes( int /*test_case_idx*/,
                         CvSize** sizes, int** types, CvSize** whole_sizes, bool *are_images );
     void generate_scalars( int depth );
+    void finalize_scalar( CvScalar& s );
     CvScalar alpha, beta, gamma;
     int gen_scalars;
     bool calc_abs;
@@ -170,6 +171,13 @@ void CxCore_ArithmTestImpl::generate_scalars( int depth )
     }
 }
 
+void CxCore_ArithmTestImpl::finalize_scalar( CvScalar& s )
+{
+    int depth = CV_MAT_DEPTH(test_mat[INPUT][0].type);
+    if( depth < CV_32F )
+        s = cvScalar(cvRound(s.val[0]), cvRound(s.val[1]), cvRound(s.val[2]), cvRound(s.val[3]));
+}
+
 void CxCore_ArithmTestImpl::get_test_array_types_and_sizes( int test_case_idx,
                                                             CvSize** sizes, int** types )
 {
@@ -338,6 +346,7 @@ CxCore_AddSTest::CxCore_AddSTest()
 
 void CxCore_AddSTest::run_func()
 {
+    finalize_scalar(gamma);
     if(!test_nd)
     {
         if( test_mat[INPUT][0].cols % 2 == 0 )
@@ -381,6 +390,7 @@ CxCore_SubRSTest::CxCore_SubRSTest()
 
 void CxCore_SubRSTest::run_func()
 {
+    finalize_scalar(gamma);
     if(!test_nd)
     {
         cvSubRS( test_array[INPUT][0], gamma,
@@ -517,6 +527,7 @@ CxCore_AbsDiffSTest::CxCore_AbsDiffSTest()
 
 void CxCore_AbsDiffSTest::run_func()
 {
+    finalize_scalar(gamma);
     if(!test_nd)
     {
         cvAbsDiffS( test_array[INPUT][0], test_array[OUTPUT][0], gamma );
index c94805da2d33062fa02b772913304a231b7e662f..b160ac7f63aa69784d3b612977f3b2d7fd9bce6c 100644 (file)
@@ -169,6 +169,26 @@ static void change_color( int color )
 
 #endif
 
+
+// reads 16-digit hexadecimal number (i.e. 64-bit integer)
+static int64 read_seed( const char* str )
+{
+    int64 val = 0;
+    if( str && strlen(str) == 16 )
+    {
+        for( int i = 0; str[i]; i++ )
+        {
+            int c = tolower(str[i]);
+            if( !isxdigit(c) )
+                return 0;
+            val = val * 16 +
+            (str[i] < 'a' ? str[i] - '0' : str[i] - 'a' + 10);
+        }
+    }
+    return val;
+}
+
+
 /***************************** memory manager *****************************/
 
 typedef struct CvTestAllocBlock
@@ -1076,7 +1096,7 @@ void CvTS::clear()
         free( ostrm_base_name );
         ostrm_base_name = 0;
     }
-    params.rng_seed = (uint64)-1;
+    params.rng_seed = 0;
     params.debug_mode = -1;
     params.print_only_failed = 0;
     params.skip_header = 0;
@@ -1333,6 +1353,12 @@ int CvTS::run( int argc, char** argv )
             params.test_filter_pattern = argv[++i];
             params.test_filter_mode = CHOOSE_TESTS;
         }
+        else if( strcmp( argv[i], "-seed" ) == 0 )
+        {
+            params.rng_seed = read_seed(argv[++i]);
+            if( params.rng_seed == 0 )
+                fprintf(stderr, "Invalid or zero RNG seed. Will use the seed from the config file or default one\n");
+        }
     }
 
 #if 0
@@ -1630,22 +1656,8 @@ int CvTS::read_params( CvFileStorage* fs )
     if( params.test_case_count_scale <= 0 )
         params.test_case_count_scale = 1.;
     str = cvReadStringByName( fs, node, "seed", 0 );
-    params.rng_seed = 0;
-    if( str && strlen(str) == 16 )
-    {
-        params.rng_seed = 0;
-        for( int i = 0; i < 16; i++ )
-        {
-            int c = tolower(str[i]);
-            if( !isxdigit(c) )
-            {
-                params.rng_seed = 0;
-                break;
-            }
-            params.rng_seed = params.rng_seed * 16 +
-                (str[i] < 'a' ? str[i] - '0' : str[i] - 'a' + 10);
-        }
-    }
+    if( str && params.rng_seed == 0 )
+        params.rng_seed = read_seed(str);
 
     if( params.rng_seed == 0 )
         params.rng_seed = cvGetTickCount();
index 610b4baa26b75d533a3eaab5889a7ba2a3ad9eae..0c10f658c4221bcf3c1ab2487ec1fd2bd59176a8 100644 (file)
@@ -431,7 +431,7 @@ protected:
 
     // reads common parameters of the test system; called from init()
     virtual int read_params( CvFileStorage* fs );
-
+    
     // checks, whether the test needs to be run (1) or not (0); called from run()
     virtual int filter( CvTest* test );