简体   繁体   中英

Difference in cv2.VideoCapture frame rate depending on initialization argument

When using OpenCV 3.4.3 cv2.VideoCapture(0) on Linux, the capture instance is created using the device index:

cap = cv2.VideoCapture(0)

I noticed the frame rate didn't appear to be very good, and after a while of playing around I modified it to use the device path:

cap = cv2.VideoCapture('/dev/video0')

After the change, the frame rate appeared to be higher. I haven't looked through the source for OpenCV (yet) to determine what the essential difference is between the 2 uses, but was wondering if there was a description of them where the frame rate could be impacted. Specifics as to access methods (v4l2, etc) that might be used in one case versus the other would be helpful.

From the docs it looks like in the first one you are passing it a device id whereas in the second one you are giving it a filename. It may be able to buffer more frames in the file, so the framerate is higher.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM