Ask Your Question

George Sid.'s profile - activity

2019-12-17 19:57:27 -0600 received badge  Famous Question (source)
2018-11-05 06:06:20 -0600 received badge  Notable Question (source)
2018-07-19 08:50:09 -0600 received badge  Popular Question (source)
2017-05-19 06:54:38 -0600 received badge  Enthusiast
2017-05-18 14:18:32 -0600 commented answer VideoCapture captures at low fps

Is there a "more" real-time approach for ~120 fps capture?

2017-05-17 02:47:49 -0600 received badge  Student (source)
2017-05-16 10:35:02 -0600 asked a question VideoCapture captures at low fps

Hello

I have a camera that captures video (according to the specifications) at a resolution of 640x480 at 120fps. I use the script below to check the speed I can capture frames with OpenCV on Python, but unfortunately I can't capture at the same speed, not even close.

import cv2
from time import time

cap = cv2.VideoCapture(2)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)

start = time()
for i in range(120):
    _, frame = cap.read()

end = time()

print("FPS: {}".format(120/(end-start)))

cap.release()

By settingCAP_PROP_FRAME_WIDTH and CAP_PROP_FRAME_HEIGHT properties I get a difference of +3 fps. Setting the CAP_PROP_FPS property to any value does not make any difference. The fps I get using the above script is FPS: 31.842164199216985. Without setting anything or just the CAP_PROP_FPS I get: FPS: 28.553502962704776.

I recorded a video with a recorder to see if the camera can actually get that kind of speed and the result, although not close enough to 120, is 50fps. I can see that there is probably a problem with the camera itself, but the difference between the code and the recorder is still at 20 fps.

So the question is: Why I can't get higher fps capture with OpenCV on Python, at least as close as the video I recorded? Can I get high (~120) fps capture at all? If yes, which camera does actually work (with OpenCV)?

Thank you in advance