视频错误:V4L:找不到摄像头设备 [英] VIDEOIO ERROR: V4L: can't find camera device
问题描述
我正在使用 ubuntu16.04 并尝试运行 opencv 脚本.当我使用:
I am using ubuntu16.04 and trying to run opencv script. when i use:
video_capture = cv2.VideoCapture(-1)
它给了我错误视频错误:V4L:找不到相机设备没有视频窗口打开但是当我跑
it gives me error VIDEOIO ERROR: V4L: can't find camera device No video window opens But when i run
video_capture = cv2.VideoCapture('test.jpg')
它打开窗口显示图片并关闭窗口.请告诉我为什么它不直接从相机流式传输视频.
It opens window shows the picture and close the window. Please tell me why it is not streaming video directly from camera.
推荐答案
api55 在评论中给出的建议
The suggestion api55 gave in his comment
video_capture = cv2.VideoCapture(0)
是我会首先尝试的.
通常,您可以使用 ls/dev/video*
或 v4l2-ctl --list-devices
列出可用的摄像机.这里的示例输出:
Generally, you can list the available cameras with ls /dev/video*
or v4l2-ctl --list-devices
. Here sample output:
NZXT-U:rt-trx> v4l2-ctl --list-devices
Microsoft® LifeCam Cinema(TM): (usb-0000:00:14.0-1):
/dev/video1
Microsoft® LifeCam Cinema(TM): (usb-0000:00:1a.0-1.3):
/dev/video0
/dev/video0
对应设备 id 0 等
/dev/video0
corresponds to device id 0, etc.
PS:v4l2-ctl
对于解决相机问题非常有用,并且可以做的远不止 --list-devices
.我通过 packagev4l-utils
在 16.04 机器上安装了它.
PS: v4l2-ctl
is quite useful for solving camera issues and can do much more than --list-devices
. I installed it via packagev4l-utils
on a 16.04 machine.
这篇关于视频错误:V4L:找不到摄像头设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!