amazon-web-servicesopencvflask

Opencv VideoCapture() when hosted on AWS Elastic Beanstalk


Recently I deployed a Flask web application to Elastic Beanstalk. One of the issues I am having is getting video capture to work with Opencv. The problem is my macbook webcam never turns on when cv2.VideoCapture(0) is called, thus never returning any frames. I deployed the app to heroku as well and encountered the same exact issue. I know the code is not the issue because everything works perfectly on localhost, with the webcam successfully turning on and returning data. What could be the issue? I know something is going wrong when I deploy the app to the web.


Solution

  • The cloud servers your are deploying to don't have access to your local webcam. In this sort of scenario, you would have to capture video locally and upload it alongside your OpenCV app. Instead of capturing from a webcam, you will have to load from a file.