[英]Read from linux web camera using OpenCV
我正在嘗試從連接到我的 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。
我很感激任何關於如何解決它的幫助或建議。 謝謝你。
最終想通了 - 我有 LP_PRELOAD 強制加載 l4lib 而不是 l4v2。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.