Create openCV VideoCapture from interface name instead of camera numbers

后端 未结 5 931
眼角桃花
眼角桃花 2020-12-17 20:13

The normal way to create a videocapture is this:

cam = cv2.VideoCapture(n)

where n corresponds to the number of /dev/video0,

5条回答
  •  别那么骄傲
    2020-12-17 20:37

    Each of my video4linux devices creates 2 device nodes. For example, /dev/video0 and /dev/video1 are both related to my internal webcam. When I plug in a second USB webcam, /dev/video2 and /dev/video3 both appear. However, I can only use the lower-numbered device of each pair for video capture (i.e. /dev/video0 and /dev/video2).

    I watched my device arrival with udevadm monitor, and then inspected each of the camera devices with udevadm info --path=$PATH_FROM_UDEVADM_MONITOR --attribute-walk. The devices which work for video capture have ATTR{index}=="0".

    Maybe instead of trying to open /dev/video1, you just need to open /dev/video0:

    cam = cv2.CaptureVideo("/dev/video0")
    

提交回复
热议问题