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 #91 from robmarkcole/fix-image-race-condition
Browse files Browse the repository at this point in the history
Fix image race condition
  • Loading branch information
robmarkcole authored Nov 17, 2019
2 parents 7d11c5e + cd0236b commit 0721774
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions custom_components/deepstack_object/image_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
CONF_TIMEOUT = "timeout"
CONF_SAVE_FILE_FOLDER = "save_file_folder"
CONF_SAVE_TIMESTAMPTED_FILE = "save_timestamped_file"
DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
DATETIME_FORMAT = "%Y-%m-%d_%H:%M:%S"
DEFAULT_API_KEY = ""
DEFAULT_TARGET = "person"
DEFAULT_TIMEOUT = 10
Expand Down Expand Up @@ -220,7 +220,12 @@ def save_image(self, image, predictions, target, directory):
timestamp_save_path = directory + "{}_{}_{}.jpg".format(
self._name, target, self._last_detection
)
img.save(timestamp_save_path)

out_file = open(timestamp_save_path, "wb")
img.save(out_file, format="JPEG")
out_file.flush()
os.fsync(out_file)
out_file.close()
self.fire_saved_file_event(timestamp_save_path)
_LOGGER.info("Saved bounding box image to %s", timestamp_save_path)

Expand Down

0 comments on commit 0721774

Please sign in to comment.