robmarkcole / HASS-Deepstack-object

Home Assistant custom component for using Deepstack object detection
https://community.home-assistant.io/t/face-and-person-detection-with-deepstack-local-and-free/92041
MIT License
440 stars 99 forks source link

Old images sometimes fired in notifications #80

Closed robmarkcole closed 5 years ago

robmarkcole commented 5 years ago

The image_processing.file_saved event is duplicating functionality of folder_watcher and sometimes causing old images to be fired in notifications as they have not yet saved to disk when the event is fired. Remove this event

robmarkcole commented 5 years ago

It is a race condition, I think it can be resolved using flush. http://discourse.techart.online/t/pil-wait-for-image-save/3994/9

In the meantime the folder_watcher option works just fine, see here

robmarkcole commented 5 years ago

To try:

output_filename = "cat_2.jpg"
out_file = open(output_filename, 'wb')
image.save(out_file, format='JPEG')  # Must specify desired format here
out_file.flush()
os.fsync(out_file)
out_file.close()
print('saved cat_2.jpg')

In https://github.com/robmarkcole/HASS-Deepstack-object/blob/fix-image-race-condition/custom_components/deepstack_object/image_processing.py

robmarkcole commented 5 years ago

I have confirmed that at least for me, this is actually an issue with my camera (blink) that sometimes does not update correctly. I am closing this issue unless someone can conclusively demonstrate that the issue is here