@@ -38,6 +38,7 @@ def test_cudaarithm(self):
38
38
def test_arithmetic (self ):
39
39
npMat1 = np .random .random ((128 , 128 , 3 )) - 0.5
40
40
npMat2 = np .random .random ((128 , 128 , 3 )) - 0.5
41
+ scalar = np .random .random ()
41
42
42
43
cuMat1 = cv .cuda_GpuMat ()
43
44
cuMat2 = cv .cuda_GpuMat ()
@@ -48,36 +49,54 @@ def test_arithmetic(self):
48
49
self .assertTrue (np .allclose (cv .cuda .add (cuMat1 , cuMat2 ).download (),
49
50
cv .add (npMat1 , npMat2 )))
50
51
52
+ self .assertTrue (np .allclose (cv .cuda .addWithScalar (cuMat1 , [scalar ]* 3 ).download (),
53
+ cv .add (npMat1 , scalar )))
54
+
51
55
cv .cuda .add (cuMat1 , cuMat2 , cuMatDst )
52
56
self .assertTrue (np .allclose (cuMatDst .download (),cv .add (npMat1 , npMat2 )))
53
57
54
58
self .assertTrue (np .allclose (cv .cuda .subtract (cuMat1 , cuMat2 ).download (),
55
59
cv .subtract (npMat1 , npMat2 )))
56
60
61
+ self .assertTrue (np .allclose (cv .cuda .subtractWithScalar (cuMat1 , [scalar ]* 3 ).download (),
62
+ cv .subtract (npMat1 , scalar )))
63
+
57
64
cv .cuda .subtract (cuMat1 , cuMat2 , cuMatDst )
58
65
self .assertTrue (np .allclose (cuMatDst .download (),cv .subtract (npMat1 , npMat2 )))
59
66
60
67
self .assertTrue (np .allclose (cv .cuda .multiply (cuMat1 , cuMat2 ).download (),
61
68
cv .multiply (npMat1 , npMat2 )))
62
69
70
+ self .assertTrue (np .allclose (cv .cuda .multiplyWithScalar (cuMat1 , [scalar ]* 3 ).download (),
71
+ cv .multiply (npMat1 , scalar )))
72
+
63
73
cv .cuda .multiply (cuMat1 , cuMat2 , cuMatDst )
64
74
self .assertTrue (np .allclose (cuMatDst .download (),cv .multiply (npMat1 , npMat2 )))
65
75
66
76
self .assertTrue (np .allclose (cv .cuda .divide (cuMat1 , cuMat2 ).download (),
67
77
cv .divide (npMat1 , npMat2 )))
68
78
79
+ self .assertTrue (np .allclose (cv .cuda .divideWithScalar (cuMat1 , [scalar ]* 3 ).download (),
80
+ cv .divide (npMat1 , scalar )))
81
+
69
82
cv .cuda .divide (cuMat1 , cuMat2 , cuMatDst )
70
83
self .assertTrue (np .allclose (cuMatDst .download (),cv .divide (npMat1 , npMat2 )))
71
84
72
85
self .assertTrue (np .allclose (cv .cuda .absdiff (cuMat1 , cuMat2 ).download (),
73
86
cv .absdiff (npMat1 , npMat2 )))
74
87
88
+ self .assertTrue (np .allclose (cv .cuda .absdiffWithScalar (cuMat1 , [scalar ]* 3 ).download (),
89
+ cv .absdiff (npMat1 , scalar )))
90
+
75
91
cv .cuda .absdiff (cuMat1 , cuMat2 , cuMatDst )
76
92
self .assertTrue (np .allclose (cuMatDst .download (),cv .absdiff (npMat1 , npMat2 )))
77
93
78
94
self .assertTrue (np .allclose (cv .cuda .compare (cuMat1 , cuMat2 , cv .CMP_GE ).download (),
79
95
cv .compare (npMat1 , npMat2 , cv .CMP_GE )))
80
96
97
+ self .assertTrue (np .allclose (cv .cuda .compareWithScalar (cuMat1 , [scalar ]* 3 , cv .CMP_GE ).download (),
98
+ cv .compare (npMat1 , scalar , cv .CMP_GE )))
99
+
81
100
cuMatDst1 = cv .cuda_GpuMat (cuMat1 .size (),cv .CV_8UC3 )
82
101
cv .cuda .compare (cuMat1 , cuMat2 , cv .CMP_GE , cuMatDst1 )
83
102
self .assertTrue (np .allclose (cuMatDst1 .download (),cv .compare (npMat1 , npMat2 , cv .CMP_GE )))
@@ -111,6 +130,7 @@ def test_arithmetic(self):
111
130
def test_logical (self ):
112
131
npMat1 = (np .random .random ((128 , 128 )) * 255 ).astype (np .uint8 )
113
132
npMat2 = (np .random .random ((128 , 128 )) * 255 ).astype (np .uint8 )
133
+ scalar = np .random .random ()
114
134
115
135
cuMat1 = cv .cuda_GpuMat ()
116
136
cuMat2 = cv .cuda_GpuMat ()
@@ -121,18 +141,27 @@ def test_logical(self):
121
141
self .assertTrue (np .allclose (cv .cuda .bitwise_or (cuMat1 , cuMat2 ).download (),
122
142
cv .bitwise_or (npMat1 , npMat2 )))
123
143
144
+ self .assertTrue (np .allclose (cv .cuda .bitwise_or_with_scalar (cuMat1 , scalar ).download (),
145
+ cv .bitwise_or (npMat1 , scalar )))
146
+
124
147
cv .cuda .bitwise_or (cuMat1 , cuMat2 , cuMatDst )
125
148
self .assertTrue (np .allclose (cuMatDst .download (),cv .bitwise_or (npMat1 , npMat2 )))
126
149
127
150
self .assertTrue (np .allclose (cv .cuda .bitwise_and (cuMat1 , cuMat2 ).download (),
128
151
cv .bitwise_and (npMat1 , npMat2 )))
129
152
153
+ self .assertTrue (np .allclose (cv .cuda .bitwise_and_with_scalar (cuMat1 , scalar ).download (),
154
+ cv .bitwise_and (npMat1 , scalar )))
155
+
130
156
cv .cuda .bitwise_and (cuMat1 , cuMat2 , cuMatDst )
131
157
self .assertTrue (np .allclose (cuMatDst .download (),cv .bitwise_and (npMat1 , npMat2 )))
132
158
133
159
self .assertTrue (np .allclose (cv .cuda .bitwise_xor (cuMat1 , cuMat2 ).download (),
134
160
cv .bitwise_xor (npMat1 , npMat2 )))
135
161
162
+ self .assertTrue (np .allclose (cv .cuda .bitwise_xor_with_scalar (cuMat1 , scalar ).download (),
163
+ cv .bitwise_xor (npMat1 , scalar )))
164
+
136
165
cv .cuda .bitwise_xor (cuMat1 , cuMat2 , cuMatDst )
137
166
self .assertTrue (np .allclose (cuMatDst .download (),cv .bitwise_xor (npMat1 , npMat2 )))
138
167
@@ -145,12 +174,18 @@ def test_logical(self):
145
174
self .assertTrue (np .allclose (cv .cuda .min (cuMat1 , cuMat2 ).download (),
146
175
cv .min (npMat1 , npMat2 )))
147
176
177
+ self .assertTrue (np .allclose (cv .cuda .minWithScalar (cuMat1 , scalar ).download (),
178
+ cv .min (npMat1 , scalar )))
179
+
148
180
cv .cuda .min (cuMat1 , cuMat2 , cuMatDst )
149
181
self .assertTrue (np .allclose (cuMatDst .download (),cv .min (npMat1 , npMat2 )))
150
182
151
183
self .assertTrue (np .allclose (cv .cuda .max (cuMat1 , cuMat2 ).download (),
152
184
cv .max (npMat1 , npMat2 )))
153
185
186
+ self .assertTrue (np .allclose (cv .cuda .maxWithScalar (cuMat1 , scalar ).download (),
187
+ cv .max (npMat1 , scalar )))
188
+
154
189
cv .cuda .max (cuMat1 , cuMat2 , cuMatDst )
155
190
self .assertTrue (np .allclose (cuMatDst .download (),cv .max (npMat1 , npMat2 )))
156
191
0 commit comments