39
39
//
40
40
//M*/
41
41
#include " test_precomp.hpp"
42
+ #include " opencv2/ts/ocl_test.hpp"
42
43
43
44
using namespace cv ;
44
45
using namespace std ;
@@ -54,7 +55,7 @@ using namespace std;
54
55
class CV_MomentsTest : public cvtest ::ArrayTest
55
56
{
56
57
public:
57
- CV_MomentsTest ();
58
+ CV_MomentsTest (bool try_umat );
58
59
59
60
protected:
60
61
@@ -65,18 +66,17 @@ class CV_MomentsTest : public cvtest::ArrayTest
65
66
void get_minmax_bounds ( int i, int j, int type, Scalar& low, Scalar& high );
66
67
double get_success_error_level ( int test_case_idx, int i, int j );
67
68
void run_func ();
68
- int coi;
69
69
bool is_binary;
70
- bool try_umat ;
70
+ bool try_umat_ ;
71
71
};
72
72
73
73
74
- CV_MomentsTest::CV_MomentsTest ()
74
+ CV_MomentsTest::CV_MomentsTest (bool try_umat) :
75
+ try_umat_(try_umat)
75
76
{
76
77
test_array[INPUT].push_back (NULL );
77
78
test_array[OUTPUT].push_back (NULL );
78
79
test_array[REF_OUTPUT].push_back (NULL );
79
- coi = -1 ;
80
80
is_binary = false ;
81
81
OCL_TUNING_MODE_ONLY (test_case_count = 10 );
82
82
// element_wise_relative_error = false;
@@ -110,40 +110,24 @@ void CV_MomentsTest::get_test_array_types_and_sizes( int test_case_idx,
110
110
{
111
111
RNG& rng = ts->get_rng ();
112
112
cvtest::ArrayTest::get_test_array_types_and_sizes ( test_case_idx, sizes, types );
113
- int cn = (cvtest::randInt (rng) % 4 ) + 1 ;
114
113
int depth = cvtest::randInt (rng) % 4 ;
115
114
depth = depth == 0 ? CV_8U : depth == 1 ? CV_16U : depth == 2 ? CV_16S : CV_32F;
116
115
117
116
is_binary = cvtest::randInt (rng) % 2 != 0 ;
118
- if ( depth == 0 && !is_binary )
119
- try_umat = cvtest::randInt (rng) % 5 != 0 ;
120
- else
121
- try_umat = cvtest::randInt (rng) % 2 != 0 ;
122
-
123
- if ( cn == 2 || try_umat )
124
- cn = 1 ;
125
117
126
118
OCL_TUNING_MODE_ONLY (
127
- cn = 1 ;
128
119
depth = CV_8U;
129
- try_umat = true ;
130
120
is_binary = false ;
131
121
sizes[INPUT][0 ] = Size (1024 ,768 )
132
122
);
133
123
134
- types[INPUT][0 ] = CV_MAKETYPE (depth, cn );
124
+ types[INPUT][0 ] = CV_MAKETYPE (depth, 1 );
135
125
types[OUTPUT][0 ] = types[REF_OUTPUT][0 ] = CV_64FC1;
136
126
sizes[OUTPUT][0 ] = sizes[REF_OUTPUT][0 ] = cvSize (MOMENT_COUNT,1 );
137
127
if (CV_MAT_DEPTH (types[INPUT][0 ])>=CV_32S)
138
128
sizes[INPUT][0 ].width = MAX (sizes[INPUT][0 ].width , 3 );
139
129
140
- coi = 0 ;
141
130
cvmat_allowed = true ;
142
- if ( cn > 1 )
143
- {
144
- coi = cvtest::randInt (rng) % cn;
145
- cvmat_allowed = false ;
146
- }
147
131
}
148
132
149
133
@@ -156,13 +140,6 @@ double CV_MomentsTest::get_success_error_level( int /*test_case_idx*/, int /*i*/
156
140
int CV_MomentsTest::prepare_test_case ( int test_case_idx )
157
141
{
158
142
int code = cvtest::ArrayTest::prepare_test_case ( test_case_idx );
159
- if ( code > 0 )
160
- {
161
- int cn = test_mat[INPUT][0 ].channels ();
162
- if ( cn > 1 )
163
- cvSetImageCOI ( (IplImage*)test_array[INPUT][0 ], coi + 1 );
164
- }
165
-
166
143
return code;
167
144
}
168
145
@@ -171,7 +148,7 @@ void CV_MomentsTest::run_func()
171
148
{
172
149
CvMoments* m = (CvMoments*)test_mat[OUTPUT][0 ].ptr <double >();
173
150
double * others = (double *)(m + 1 );
174
- if ( try_umat )
151
+ if (try_umat_ )
175
152
{
176
153
UMat u;
177
154
test_mat[INPUT][0 ].clone ().copyTo (u);
@@ -212,6 +189,7 @@ void CV_MomentsTest::prepare_to_validation( int /*test_case_idx*/ )
212
189
213
190
memset ( &m, 0 , sizeof (m));
214
191
192
+ int coi = 0 ;
215
193
for ( y = 0 ; y < src.rows ; y++ )
216
194
{
217
195
double s0 = 0 , s1 = 0 , s2 = 0 , s3 = 0 ;
@@ -431,7 +409,8 @@ void CV_HuMomentsTest::prepare_to_validation( int /*test_case_idx*/ )
431
409
}
432
410
433
411
434
- TEST (Imgproc_Moments, accuracy) { CV_MomentsTest test; test.safe_run (); }
412
+ TEST (Imgproc_Moments, accuracy) { CV_MomentsTest test (false ); test.safe_run (); }
413
+ OCL_TEST (Imgproc_Moments, accuracy) { CV_MomentsTest test (true ); test.safe_run (); }
435
414
TEST (Imgproc_HuMoments, accuracy) { CV_HuMomentsTest test; test.safe_run (); }
436
415
437
416
class CV_SmallContourMomentTest : public cvtest ::BaseTest
0 commit comments