Using device name instead of ID in OpenCV method VideoCapture.open()

后端 未结 3 835
感动是毒
感动是毒 2021-01-06 08:31

I have a lot of video devices in my /dev folder (e.g. video1, video2, ..., video9) and one /dev/video which

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-06 09:08

    with current OpenCV 3.2.0 you can create a new capture like this:

    cv::VideoCapture cap("/dev/video20", cv::CAP_V4L);
    

    its one of the additional constructors:

    VideoCapture (const String &filename, int apiPreference)
    Open video file or a capturing device or a IP video stream for video capturing with API Preference.

    this is also possible with the open function:

    cap.open("/dev/video20", cv::CAP_V4L);
    

    i have tested this successfully under Kubuntu 16.10 with self compiled openCV from current git master.

提交回复
热议问题