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

Issue221 #224

Merged
merged 3 commits into from
Feb 17, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update image_processing.py
  • Loading branch information
robmarkcole committed Feb 17, 2021
commit d84cb54b47cede8fc05ea9b7c3ff8fef83b95a22
11 changes: 8 additions & 3 deletions custom_components/deepstack_object/image_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ def __init__(
self._state = None
self._objects = [] # The parsed raw data
self._targets_found = []
self._last_detection = None

self._roi_dict = {
"y_min": roi_y_min,
Expand All @@ -305,7 +306,6 @@ def __init__(
}
self._scale = scale
self._show_boxes = show_boxes
self._last_detection = None
self._image_width = None
self._image_height = None
self._save_file_folder = save_file_folder
Expand All @@ -315,7 +315,7 @@ def __init__(

def process_image(self, image):
"""Process an image."""
self._image = Image.open(io.BytesIO(bytearray(image)))
self._image = Image.open(io.BytesIO(bytearray(image))) # used for saving only
self._image_width, self._image_height = self._image.size

# resize image if different then default
Expand Down Expand Up @@ -405,6 +405,11 @@ def name(self):
"""Return the name of the sensor."""
return self._name

@property
def unit_of_measurement(self):
"""Return the unit of measurement."""
return "targets"

@property
def should_poll(self):
"""Return the polling state."""
Expand Down Expand Up @@ -479,8 +484,8 @@ def save_image(self, targets, directory) -> str:
latest_save_path = (
directory / f"{get_valid_filename(self._name).lower()}_latest.jpg"
)
_LOGGER.info("Deepstack saved file %s", latest_save_path)
img.save(latest_save_path)
_LOGGER.info("Deepstack saved file %s", latest_save_path)
saved_image_path = latest_save_path

if self._save_timestamped_file:
Expand Down