【问题标题】:Read from linux web camera using OpenCV使用 OpenCV 从 linux 网络摄像头读取
【发布时间】:2017-02-11 16:34:49
【问题描述】:

我正在尝试从连接到我的 linux 机器的网络摄像头读取原始视频。我正在使用 OpenCV 和 l4v2 库(gstreamer)。 以下是我相机的一些细节:

root@blah:~$ v4l2-ctl -d /dev/video0 --list-formats
ioctl: VIDIOC_ENUM_FMT
        Index       : 0
        Type        : Video Capture
        Pixel Format: 'YUYV'
        Name        : YUV 4:2:2 (YUYV)

        Index       : 1
        Type        : Video Capture
        Pixel Format: ''
        Name        : e436eb7d-524f-11ce-9f53-0020af0

        Index       : 2
        Type        : Video Capture
        Pixel Format: 'RGB3' (emulated)
        Name        : RGB3

        Index       : 3
        Type        : Video Capture
        Pixel Format: 'BGR3' (emulated)
        Name        : BGR3

        Index       : 4
        Type        : Video Capture
        Pixel Format: 'YU12' (emulated)
        Name        : YU12

        Index       : 5
        Type        : Video Capture
        Pixel Format: 'YV12' (emulated)
        Name        : YV12

这是我的超级简单代码:

VideoCapture capture = VideoCapture(0);
if (!capture.isOpened()) {
      // Error in opening the video input
      cerr << "Unable to open video file for read: " << FLAGS_in_video << endl;
}
else {
  cout << "Opened video for read: " << FLAGS_in_video << endl;
}

这是我得到的输出和错误:

Trying to open device 0 to read.
VIDEOIO ERROR: V4L/V4L2: VIDIOC_S_CROP
mmap: Invalid argument
Opened video for read: 0
Unable to stop the stream.: Bad file descriptor
munmap: Invalid argument
munmap: Invalid argument
munmap: Invalid argument
munmap: Invalid argument

我已经使用 WITH_V4L 和 WITH_LIBV4L 标志构建了 OpenCV。

如果您能提供任何有关如何解决此问题的帮助或建议,我将不胜感激。谢谢。

【问题讨论】:

    标签: c++ linux opencv v4l2 v4l


    【解决方案1】:

    最终想通了 - 我有 LP_PRELOAD 强制加载 l4lib 而不是 l4v2。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-09-23
      • 2012-12-05
      • 2016-05-02
      • 2015-07-08
      • 1970-01-01
      • 1970-01-01
      • 2011-12-14
      相关资源
      最近更新 更多