@@ -270,7 +270,7 @@ def __init__(
270
270
self ._targets = targets
271
271
for target in self ._targets :
272
272
if CONF_CONFIDENCE not in target .keys ():
273
- target [ CONF_CONFIDENCE ] = self ._confidence
273
+ target . update ({ CONF_CONFIDENCE : self ._confidence })
274
274
self ._targets_names = [
275
275
target [CONF_TARGET ] for target in targets
276
276
] # can be a name or a type
@@ -319,19 +319,24 @@ def process_image(self, image):
319
319
self ._targets_found = []
320
320
321
321
for obj in self ._objects :
322
- if obj ["name" ] or obj ["object_type" ] in self ._targets_names :
323
- ## Then check if the type has a configured confidence, if yes assign
324
- ## Then if a confidence for a named object, this takes precedence over type confidence
325
- confidence = self ._confidence
326
- for target in self ._targets :
327
- if target [CONF_TARGET ] == obj ["object_type" ]:
328
- confidence = target [CONF_CONFIDENCE ]
329
- for target in self ._targets :
330
- if target [CONF_TARGET ] == obj ["name" ]:
331
- confidence = target [CONF_CONFIDENCE ]
332
- if obj ["confidence" ] > confidence :
333
- if object_in_roi (self ._roi_dict , obj ["centroid" ]):
334
- self ._targets_found .append (obj )
322
+ if not (
323
+ (obj ["name" ] in self ._targets_names )
324
+ or (obj ["object_type" ] in self ._targets_names )
325
+ ):
326
+ continue
327
+ ## Then check if the type has a configured confidence, if yes assign
328
+ ## Then if a confidence for a named object, this takes precedence over type confidence
329
+ confidence = None
330
+ for target in self ._targets :
331
+ if obj ["object_type" ] == target [CONF_TARGET ]:
332
+ confidence = target [CONF_CONFIDENCE ]
333
+ for target in self ._targets :
334
+ if obj ["name" ] == target [CONF_TARGET ]:
335
+ confidence = target [CONF_CONFIDENCE ]
336
+ if obj ["confidence" ] > confidence :
337
+ if not object_in_roi (self ._roi_dict , obj ["centroid" ]):
338
+ continue
339
+ self ._targets_found .append (obj )
335
340
336
341
self ._state = len (self ._targets_found )
337
342
if self ._state > 0 :
0 commit comments