I am having trouble reading an ~85 FPS USB webcam Windows, on average I am measuring 85 Hz but its being read in bursts.
I have a python script like below to capture images
import cv2 as cv
import sys
from datetime import datetime
previous_time = datetime.now()
n = int(sys.argv[1])
cam = cv.VideoCapture(n)
while 1:
ret,frame = cam.read()
now = datetime.now()
td = (now-previous_time).microseconds
previous_time = now
print("Frame delta, {} ms".format(td/1000))
When looking at the printed output, the time delta between frames is either 30 ms or near 0ms.
Frame delta, 30.877 ms
Frame delta, 0.0 ms
Frame delta, 0.999 ms
Frame delta, 30.525 ms
Frame delta, 0.0 ms
Frame delta, 0.997 ms
Frame delta, 29.956 ms
I have tested the same webcam on Linux with the same script and the frame delta is a lot more consistent (close to 12 ms with +- 5ms deviation) which is what I am expecting. I have tried the Microsoft Media foundation backend with OpenCV and also the direct show backend, both have the same behavior. I have even tried write a C++ version of the script using the Microsoft Media Foundation API and it has the same issue.