Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to use video capture/ read in opencv without it taking so long?

Tags:

python

opencv

There is about a 10-20 second delay between when I run my program and when the web camera actually takes the image. Is there any way to speed up this process?

I have looked several places and haven't found a solution.

    video_capture = cv2.VideoCapture(1)
    ret, frame = video_capture.read()

I just don't get what is taking these two lines of code so long to execute when I can take a picture with my webcam instantly through the normal camera application.

like image 896
madmax007 Avatar asked Nov 18 '25 00:11

madmax007


1 Answers

Ok so it took me a while but the problem was solved by switching the API. I changed the line of code:

  video_capture = cv2.VideoCapture(1)

to

  video_capture = cv2.VideoCapture(1, cv2.CAP_DSHOW)

by adding this, it now works instantly, removing the delay which was present before.

like image 137
madmax007 Avatar answered Nov 20 '25 13:11

madmax007



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!