简体   繁体   English

在raspberry pi上使用Opencv显示视频流时出错

[英]Error displaying video stream using Opencv on raspberry pi

I'm trying to access a live video feed from my Raspberry Pi with a PiCam attached. 我正试图通过附加的PiCam从我的Raspberry Pi访问实时视频。 I have enabled the camera in the interface settings and even tested it by snapping some pictures and videos using the PiCam library. 我已经在界面设置中启用了相机,甚至通过使用PiCam库捕捉一些图片和视频进行了测试。 However, OpenCV is giving me troubles. 但是,OpenCV给了我麻烦。 I installed open CV following this tutorial (shoutout to Adrian Rosenbrock). 我按照本教程安装了开放式简历(向Adrian Rosenbrock发送电子邮件)。

Check out the screenshot below for the code and the error message. 查看下面的屏幕截图,了解代码和错误消息。 I'm running everything from within a virtual environment with OpenCV installed, like Adrian suggests. 我正在安装OpenCV的虚拟环境中运行所有内容,就像Adrian建议的那样。

Code and error message 代码和错误消息

VIDEOIO ERROR: V4L: can't open camera by index 0 VIDEOIO ERROR:V4L:无法通过索引0打开相机

From what I've read from other problems people have had, this error is sometimes resolved by playing with the index value. 从我从人们遇到的其他问题中读到的内容,有时通过使用索引值来解决此错误。 If i change the index value to -1 or 1, like most solutions suggest, i either get the same thing or a slightly different "can't access camera" error. 如果我将索引值更改为-1或1,就像大多数解决方案所示,我要么得到相同的东西,要么略有不同“无法访问摄像头”错误。

I'm relatively new to OpenCV and RPi so I might just be missing something simple. 我对OpenCV和RPi比较陌生,所以我可能会错过一些简单的东西。 Any suggestion is much appreciated, thanks! 任何建议都非常感谢,谢谢!

You may need to enable access to the camera. 您可能需要启用对相机的访问权限。 Try typing: sudo modprobe bcm2835-v4l2 in terminal on your RPI. 尝试在RPI的终端输入: sudo modprobe bcm2835-v4l2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM