0

I'm Using OpenCv for detecting the face. I'm fetching image from the video. When I'm running the code on my local machine to capture video, it's working fine. But when running the same code after deployment on Heroku it's not working.

Below is the error-

[ WARN:0] global /tmp/pip-req-build-dzetuct2/opencv/modules/videoio/src/cap_v4l.cpp (890) open VIDEOIO(V4L2:/dev/video1): can't open camera by index

Below is the code-

Views.py

class VideoCamera(object):
    def __init__(self):
        self.video = cv2.VideoCapture(1)

        camera_backends = cv2.videoio_registry.getCameraBackends()
        print("ca",camera_backends)
        (self.grabbed, self.frame) = self.video.read()
        threading.Thread(target=self.update, args=()).start()

    def __del__(self):
        self.video.release()

    def get_frame(self):
        image = self.frame
        _, jpeg = cv2.imencode('.jpg', image)
        return jpeg.tobytes()

    def update(self):
        while True:
            (self.grabbed, self.frame) = self.video.read()

I tried using index value 1 and 2 both but did not work for me.

Someone Please help. Thanks in advance.

Meera
  • 25
  • 1
  • 10

2 Answers2

0

Have you tried 0? - (Because this is what works for me, assuming that you too are using your device camera)

self.video = cv2.VideoCapture(0)
0

The issue is not with the code but with the Heroku.

Here is the link I got, that answers my question-

Flask app working on local server but not globally

Meera
  • 25
  • 1
  • 10