I've deployed my flask application on Nginx and gunicorn but when I try to open VideoCapture it returns an Internal Server Error. When i check the logs the error boils down to a cv2 error where the app cannot open the mobile phone camera whereas it could open my laptops camera when I run it in the development server(using python3 run.py). the closest I've gotten to the answer is this stackoverflow answer that requires me to rewrite my code in Javascript or webtrc none of which I'm familiar with.
Here's a copy of my log file
[ WARN:0@2490.519] global
/io/opencv/modules/videoio/src/cap_v4l.cpp (889) open
VIDEOIO(V4L2:/dev/video0): can't open camera by index
[2022-09-15 11:50:03 +0300] [14358] [ERROR] Error handling
request /markin
Traceback (most recent call last):
File "/home/dancungerald/Documents/Python/flask_app/app_venv/lib/python3.8 /site-packages/gunicorn/workers/sync.py", line 136, in handle self.handle_request(listener, req, client, addr) File
"/home/dancungerald/Documents/Python/flask_app/app_venv/lib/python3.8/site-packages/gunicorn/workers/sync.py", line 179, in handle_request respiter = self.wsgi(environ, resp.start_response) File "/home/dancungerald/Documents/Python/flask_app/app_venv/lib/lib/python3.8/site-packages/flask/app.py", line 2464, in call return self.wsgi_app(environ, start_response) File "/home/dancungerald/Documents/Python/flask_app/app_venv/lib/lib/python3.8/site-packages/flask/app.py", line 2450, in wsgi_app response = self.handle_exception(e) File "/home/dancungerald/Documents/Python/flask_app/app_venv/lib/lib/python3.8/site-packages/flask/app.py", line 1867, in handle_exception reraise(exc_type, exc_value, tb) File "/home/dancungerald/Documents/Python/flask_app/app_venv/lib/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise raise value File "/home/dancungerald/Documents/Python/flask_app/app_venv/lib/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/home/dancungerald/Documents/Python/flask_app/app_venv/lib/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/dancungerald/Documents/Python/flask_app/app_venv/lib/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "/home/dancungerald/Documents/Python/flask_app/app_venv/lib/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise raise value File "/home/dancungerald/Documents/Python/flask_app/app_venv/lib/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/home/dancungerald/Documents/Python/flask_app/app_venv/lib/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functionsrule.endpoint File "/home/dancungerald/Documents/Python/flask_app/app_package/routes.py", line 173, in markin img= cv2.cvtColor(img, cv2.COLOR_BGR2RGB) cv2.error: OpenCV(4.5.5) /io/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
is there any other way that I could configure my app to open the user's mobile phone camera without having to rewrite my code? any contribution will be highly appreciated.