Skip to content
This repository was archived by the owner on Mar 19, 2023. It is now read-only.

Commit 823f3be

Browse files
authored
Merge pull request #198 from robmarkcole/fix-195
Fix #195
2 parents 4c4d5d8 + fbb5f65 commit 823f3be

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

custom_components/deepstack_object/image_processing.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def __init__(
270270
self._targets = targets
271271
for target in self._targets:
272272
if CONF_CONFIDENCE not in target.keys():
273-
target[CONF_CONFIDENCE] = self._confidence
273+
target.update({CONF_CONFIDENCE: self._confidence})
274274
self._targets_names = [
275275
target[CONF_TARGET] for target in targets
276276
] # can be a name or a type
@@ -319,19 +319,24 @@ def process_image(self, image):
319319
self._targets_found = []
320320

321321
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)
335340

336341
self._state = len(self._targets_found)
337342
if self._state > 0:

0 commit comments

Comments
 (0)