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

Commit

Permalink
Merge pull request #198 from robmarkcole/fix-195
Browse files Browse the repository at this point in the history
Fix #195
  • Loading branch information
robmarkcole authored Jan 14, 2021
2 parents 4c4d5d8 + fbb5f65 commit 823f3be
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions custom_components/deepstack_object/image_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def __init__(
self._targets = targets
for target in self._targets:
if CONF_CONFIDENCE not in target.keys():
target[CONF_CONFIDENCE] = self._confidence
target.update({CONF_CONFIDENCE: self._confidence})
self._targets_names = [
target[CONF_TARGET] for target in targets
] # can be a name or a type
Expand Down Expand Up @@ -319,19 +319,24 @@ def process_image(self, image):
self._targets_found = []

for obj in self._objects:
if obj["name"] or obj["object_type"] in self._targets_names:
## Then check if the type has a configured confidence, if yes assign
## Then if a confidence for a named object, this takes precedence over type confidence
confidence = self._confidence
for target in self._targets:
if target[CONF_TARGET] == obj["object_type"]:
confidence = target[CONF_CONFIDENCE]
for target in self._targets:
if target[CONF_TARGET] == obj["name"]:
confidence = target[CONF_CONFIDENCE]
if obj["confidence"] > confidence:
if object_in_roi(self._roi_dict, obj["centroid"]):
self._targets_found.append(obj)
if not (
(obj["name"] in self._targets_names)
or (obj["object_type"] in self._targets_names)
):
continue
## Then check if the type has a configured confidence, if yes assign
## Then if a confidence for a named object, this takes precedence over type confidence
confidence = None
for target in self._targets:
if obj["object_type"] == target[CONF_TARGET]:
confidence = target[CONF_CONFIDENCE]
for target in self._targets:
if obj["name"] == target[CONF_TARGET]:
confidence = target[CONF_CONFIDENCE]
if obj["confidence"] > confidence:
if not object_in_roi(self._roi_dict, obj["centroid"]):
continue
self._targets_found.append(obj)

self._state = len(self._targets_found)
if self._state > 0:
Expand Down

0 comments on commit 823f3be

Please sign in to comment.