Running webcam and opencv issues

I change the requirement.txt to include opencv-python-headless to deal with no module named cv2 issue.
Still, when I tried to run the app, it seems cannot access to webcam input.
The error message I received is like below:

error: OpenCV(4.5.1) /tmp/pip-req-build-hj027r8z/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
Traceback:
File "/usr/local/lib/python3.7/site-packages/streamlit/script_runner.py", line 332, in _run_script
    exec(code, module.__dict__)
File "/app/adas_demo/streamlit.py", line 11, in <module>
    frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

Please let me know if you have any idea on it.

I had similar problems, but my app’s access to OpenCV works now. Although I was having different problem for another webcam custom component, mentioned here.

Feel free to take a look at the requirements for my app, maybe it helps:
https://github.com/patryk-oleniuk/face-emotionz-webapp

1 Like

Are you on Streamlit >= 0.73? The permissions to allow webcams is a very recent feature.

Yes I am using 0.74.1 version. It works fine locally. That error occurred when I tried deploy.

Thanks, will take a look at it

Do the issue is resolved??? I’m getting the same problem!!

same issue :frowning_face:
any solutions yet?