@@ -11,7 +11,9 @@ class CV_BackgroundSubtractorTest : public cvtest::BaseTest
11
11
{
12
12
public:
13
13
CV_BackgroundSubtractorTest ();
14
+ void setMatType (int _mtype){ mtype = _mtype; }
14
15
protected:
16
+ int mtype;
15
17
void run (int );
16
18
};
17
19
@@ -29,11 +31,9 @@ void CV_BackgroundSubtractorTest::run(int)
29
31
{
30
32
int code = cvtest::TS::OK;
31
33
RNG& rng = ts->get_rng ();
32
- int type = ((unsigned int )rng)%7 ; // !< pick a random type, 0 - 6, defined in types_c.h
33
- int channels = 1 + ((unsigned int )rng)%4 ; // !< random number of channels from 1 to 4.
34
- int channelsAndType = CV_MAKETYPE (type,channels);
35
- int width = 2 + ((unsigned int )rng)%98 ; // !< Mat will be 2 to 100 in width and height
36
- int height = 2 + ((unsigned int )rng)%98 ;
34
+ int depth = CV_MAT_DEPTH (mtype);
35
+ int width = 64 ;
36
+ int height = 64 ;
37
37
38
38
Ptr <BackgroundSubtractorGMG> fgbg = createBackgroundSubtractorGMG ();
39
39
Mat fgmask;
@@ -57,39 +57,39 @@ void CV_BackgroundSubtractorTest::run(int)
57
57
* Max value for simulated images picked randomly in upper half of type range
58
58
* Min value for simulated images picked randomly in lower half of type range
59
59
*/
60
- if (type == CV_8U)
60
+ if (depth == CV_8U)
61
61
{
62
62
uchar half = UCHAR_MAX/2 ;
63
63
maxd = (unsigned char )rng.uniform (half+32 , UCHAR_MAX);
64
64
mind = (unsigned char )rng.uniform (0 , half-32 );
65
65
}
66
- else if (type == CV_8S)
66
+ else if (depth == CV_8S)
67
67
{
68
68
maxd = (char )rng.uniform (32 , CHAR_MAX);
69
69
mind = (char )rng.uniform (CHAR_MIN, -32 );
70
70
}
71
- else if (type == CV_16U)
71
+ else if (depth == CV_16U)
72
72
{
73
73
ushort half = USHRT_MAX/2 ;
74
74
maxd = (unsigned int )rng.uniform (half+32 , USHRT_MAX);
75
75
mind = (unsigned int )rng.uniform (0 , half-32 );
76
76
}
77
- else if (type == CV_16S)
77
+ else if (depth == CV_16S)
78
78
{
79
79
maxd = rng.uniform (32 , SHRT_MAX);
80
80
mind = rng.uniform (SHRT_MIN, -32 );
81
81
}
82
- else if (type == CV_32S)
82
+ else if (depth == CV_32S)
83
83
{
84
84
maxd = rng.uniform (32 , INT_MAX);
85
85
mind = rng.uniform (INT_MIN, -32 );
86
86
}
87
- else if (type == CV_32F)
87
+ else if (depth == CV_32F)
88
88
{
89
89
maxd = rng.uniform (32 .0f , FLT_MAX);
90
90
mind = rng.uniform (-FLT_MAX, -32 .0f );
91
91
}
92
- else if (type == CV_64F)
92
+ else if (depth == CV_64F)
93
93
{
94
94
maxd = rng.uniform (32.0 , DBL_MAX);
95
95
mind = rng.uniform (-DBL_MAX, -32.0 );
@@ -98,7 +98,7 @@ void CV_BackgroundSubtractorTest::run(int)
98
98
fgbg->setMinVal (mind);
99
99
fgbg->setMaxVal (maxd);
100
100
101
- Mat simImage = Mat::zeros (height, width, channelsAndType );
101
+ Mat simImage = Mat::zeros (height, width, mtype );
102
102
int numLearningFrames = 120 ;
103
103
for (int i = 0 ; i < numLearningFrames; ++i)
104
104
{
@@ -132,6 +132,19 @@ void CV_BackgroundSubtractorTest::run(int)
132
132
133
133
}
134
134
135
- TEST (VIDEO_BGSUBGMG, accuracy) { CV_BackgroundSubtractorTest test; test.safe_run (); }
135
+ typedef testing::TestWithParam<std::tuple<perf::MatDepth,int >> bgsubgmg_allTypes;
136
+ TEST_P (bgsubgmg_allTypes, accuracy)
137
+ {
138
+ const int mtype = CV_MAKETYPE (get<0 >(GetParam ()), get<1 >(GetParam ()));
139
+ CV_BackgroundSubtractorTest test;
140
+ test.setMatType (mtype);
141
+ test.safe_run ();
142
+ }
143
+
144
+ INSTANTIATE_TEST_CASE_P (/* */ ,
145
+ bgsubgmg_allTypes,
146
+ testing::Combine (
147
+ testing::Values (CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F),
148
+ testing::Values(1 ,2 ,3 ,4 )));
136
149
137
150
}} // namespace
0 commit comments