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