1
- from typing import List , Optional , Union
1
+ from typing import List , Optional
2
2
3
3
import depthai as dai
4
4
import pytest
@@ -16,11 +16,6 @@ def resize_height():
16
16
return 256
17
17
18
18
19
- def test_rvc3_unsupported (resize_width , resize_height ):
20
- with pytest .raises (ValueError , match = "Unsupported" ):
21
- generate_script_content ("rvc3" , resize_width , resize_height )
22
-
23
-
24
19
class ImageManipConfigV2 (dai .ImageManipConfigV2 ):
25
20
def __init__ (self ):
26
21
super ().__init__ ()
@@ -168,16 +163,14 @@ def node_input_detections(node) -> List[dai.ImgDetections]:
168
163
return node .inputs [Node .INPUT_DETECTIONS_KEY ].items
169
164
170
165
171
- @pytest .mark .parametrize ("platform" , ["rvc2" , "rvc4" ])
172
166
def test_passthrough (
173
167
node ,
174
168
node_input_detections ,
175
169
node_input_frames ,
176
- platform ,
177
170
resize_width ,
178
171
resize_height ,
179
172
):
180
- script = generate_script_content (platform , resize_width , resize_height )
173
+ script = generate_script_content (resize_width , resize_height )
181
174
expected_frames = []
182
175
for frame , detections in zip (node_input_frames , node_input_detections ):
183
176
for _ in detections .detections :
@@ -191,12 +184,11 @@ def test_passthrough(
191
184
assert len (get_output_config (node )) == len (expected_frames )
192
185
193
186
194
- @pytest .mark .parametrize (( "platform" , " labels") , [( "rvc2" , [1 ]), ( "rvc4" , [1 , 2 ]) ])
187
+ @pytest .mark .parametrize (" labels" , [[1 ], [1 , 2 ]])
195
188
def test_label_validation (
196
189
node ,
197
190
node_input_detections ,
198
191
node_input_frames ,
199
- platform ,
200
192
labels ,
201
193
resize_width ,
202
194
resize_height ,
@@ -207,30 +199,16 @@ def test_label_validation(
207
199
if detection .label not in labels :
208
200
continue
209
201
expected_frames .append (frame )
210
- script = generate_script_content (
211
- platform , resize_width , resize_height , valid_labels = labels
212
- )
202
+ script = generate_script_content (resize_width , resize_height , valid_labels = labels )
213
203
try :
214
204
run_script (node , script )
215
205
except Warning :
216
206
assert expected_frames == get_output_frames (node )
217
207
218
208
219
209
@pytest .mark .parametrize ("resize" , [(128 , 128 ), (128 , 256 ), (256 , 256 )])
220
- def test_rvc2_output_size (node , resize ):
221
- script = generate_script_content ("rvc2" , * resize )
222
- try :
223
- run_script (node , script )
224
- except Warning :
225
- output_cfg = get_output_config (node )
226
- for cfg in output_cfg :
227
- assert isinstance (cfg , dai .ImageManipConfig )
228
- assert cfg .getResizeWidth (), cfg .getResizeHeight () == resize
229
-
230
-
231
- @pytest .mark .parametrize ("resize" , [(128 , 128 ), (128 , 256 ), (256 , 256 )])
232
- def test_rvc4_output_size (node , resize ):
233
- script = generate_script_content ("rvc4" , * resize )
210
+ def test_output_size (node , resize ):
211
+ script = generate_script_content (* resize )
234
212
try :
235
213
run_script (node , script )
236
214
except Warning :
@@ -241,36 +219,7 @@ def test_rvc4_output_size(node, resize):
241
219
242
220
243
221
@pytest .mark .parametrize ("padding" , [0 , 0.1 , 0.2 , - 0.1 , - 0.2 ])
244
- def test_rvc2_crop (node , node_input_detections , padding , resize_width , resize_height ):
245
- expected_rects : List [dai .ImageManipConfig .CropRect ] = []
246
- for input_dets in node_input_detections :
247
- for detection in input_dets .detections :
248
- rect = dai .ImageManipConfig .CropRect ()
249
- rect .xmin = max (detection .xmin - padding , 0 )
250
- rect .xmax = min (detection .xmax + padding , 1 )
251
- rect .ymin = max (detection .ymin - padding , 0 )
252
- rect .ymax = min (detection .ymax + padding , 1 )
253
- expected_rects .append (rect )
254
- script = generate_script_content (
255
- "rvc2" , resize_width , resize_height , padding = padding
256
- )
257
- try :
258
- run_script (node , script )
259
- except Warning :
260
- output_cfg = get_output_config (node )
261
- for cfg , expected_rect in zip (output_cfg , expected_rects ):
262
- assert isinstance (cfg , dai .ImageManipConfig )
263
- crop_rect = cfg .getCropConfig ().cropRect
264
- assert (crop_rect .xmin , crop_rect .xmax , crop_rect .ymin , crop_rect .ymax ) == (
265
- expected_rect .xmin ,
266
- expected_rect .xmax ,
267
- expected_rect .ymin ,
268
- expected_rect .ymax ,
269
- )
270
-
271
-
272
- @pytest .mark .parametrize ("padding" , [0 , 0.1 , 0.2 , - 0.1 , - 0.2 ])
273
- def test_rvc4_crop (node , node_input_detections , padding , resize_width , resize_height ):
222
+ def test_crop (node , node_input_detections , padding , resize_width , resize_height ):
274
223
ANGLE = 0
275
224
expected_rects : List [dai .RotatedRect ] = []
276
225
for input_dets in node_input_detections :
@@ -283,9 +232,7 @@ def test_rvc4_crop(node, node_input_detections, padding, resize_width, resize_he
283
232
rect .size .width = detection .xmax - detection .xmin + rect_padding
284
233
rect .size .height = detection .ymax - detection .ymin + rect_padding
285
234
expected_rects .append (rect )
286
- script = generate_script_content (
287
- "rvc4" , resize_width , resize_height , padding = padding
288
- )
235
+ script = generate_script_content (resize_width , resize_height , padding = padding )
289
236
try :
290
237
run_script (node , script )
291
238
except Warning :
@@ -310,7 +257,6 @@ def run_script(node, script):
310
257
{
311
258
"node" : node ,
312
259
"ImageManipConfigV2" : ImageManipConfigV2 ,
313
- "ImageManipConfig" : dai .ImageManipConfig ,
314
260
"RotatedRect" : dai .RotatedRect ,
315
261
},
316
262
)
@@ -322,5 +268,5 @@ def get_output_frames(node: Node) -> List[Frame]:
322
268
323
269
def get_output_config (
324
270
node : Node ,
325
- ) -> Union [ List [dai . ImageManipConfig ], List [ ImageManipConfigV2 ] ]:
271
+ ) -> List [ImageManipConfigV2 ]:
326
272
return node .outputs [Node .OUTPUT_CONFIG_KEY ].items
0 commit comments