'After deployment Cv2 can not access the webcam
I need help. I was building facial recognition using Flask. In the local browser, it was working fine but after deployed into AWS EC2 instance Ubuntu server (also pythonanywhere) is not working in the browser. Actually, cv2 did not access the webcam. (And my server is HTTP only)
Thanks in advance.
Code:-
vid = cv2.VideoCapture(0) ## 1,0,-1
Error Log :-
2021-04-02 09:12:21 initialized 38 metrics
2021-04-02 09:12:21 [ WARN:0] global /tmp/pip-req-build-ms668fyv/opencv/modules/videoio/src/cap_v4l.cpp (880) open VIDEOIO(V4L2): can't find camera device
2021-04-02 09:12:21 WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x1427ce0 pid: 1 (default app)
Solution 1:[1]
getUserMedia() for webcam does not work on insecure origins with http. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. With http, it only works on localhost.
While your error seems to be because your webcam or external camera does not correspond to 0 value. Try some different number like -1, 1, 2 on cv2.VideoCapture().
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |