thoughtworksarts / EmoPy

A deep neural net toolkit for emotion analysis via Facial Expression Recognition (FER)
https://thoughtworksarts.io/blog/emopy-emotional-expression-toolkit/
GNU Affero General Public License v3.0
919 stars 264 forks source link

Improving Webcam support #53

Closed cptanalatriste closed 4 years ago

cptanalatriste commented 4 years ago

A fix for webcam image storage and EmoPy emotion assessment.

anjutiwari commented 4 years ago

Got this error:
WARNING:tensorflow:From /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version. Instructions for updating: Use tf.cast instead. Traceback (most recent call last): File "fermodel_example_webcam.py", line 26, in cv2.imwrite(file, frame) cv2.error: OpenCV(4.1.2) /Users/travis/build/skvark/opencv-python/opencv/modules/imgcodecs/src/loadsave.cpp:715: error: (-215:Assertion failed) !_img.empty() in function 'imwrite'

anjutiwari commented 4 years ago

The code I pasted in the issue will not fail, It will exit if frames value is None.

cptanalatriste commented 4 years ago

@anjutiwari I manage to replicate the flaky image capture after executing the script multiple times.

Inspired by the code you pasted, I implemented some modifications: Now before capture, I verify access to the camera and try multiple times to obtain a frame (with a threshold for tries). Can you please check if the flakiness persist?