Python3 Open-cv Camera start delay

  opencv, python, python-3.x

I am using Opencv (import cv2) to read images from my web-camera. The device that I used to develop is a laptop. So, it already has an in-built camera in it.

I have disabled the internal camera by settings, so that it can access the web-camera directly.

But the issue is while I start to run the program it nearly takes 1min and 20seconds to start the camera from my laptop. I cant relate where the issue is.

The code that I used:

import cv2

cv2.namedWindow("preview")
vc = cv2.VideoCapture(0)

if vc.isOpened(): # try to get the first frame
    rval, frame = vc.read()
else:
    rval = False

while rval:
    cv2.imshow("preview", frame)
    rval, frame = vc.read()
    key = cv2.waitKey(20)
    if key == 27: # exit on ESC
        break

vc.release()
cv2.destroyWindow("preview")

Source: Python Questions

LEAVE A COMMENT