简体   繁体   English

Open CV无法从Raspberry Pi上的USB相机读取帧

[英]Open CV cannot read frames from USB camera on Raspberry Pi

I have a Logitech c270 usb webcam connected to my Raspberry Pi 3, running on a Jessie image. 我有一个Logitech c270 usb网络摄像头连接到我的Raspberry Pi 3,并在Jessie映像上运行。 I have tried to capture frames with this simple tutorial code on 我尝试使用以下简单的教程代码捕获帧

http://www.pyimagesearch.com/2016/02/22/writing-to-video-with-opencv/ http://www.pyimagesearch.com/2016/02/22/writing-to-video-with-opencv/

Whenever I try to read frames in the while loop, it gives out this error: 每当我尝试在while循环中读取帧时,都会发出此错误:

NoneType object has no attribute 'shape' NoneType对象没有属性“ shape”

I have printed out the vs.read() function and it also returns None object. 我已经打印出vs.read()函数,它也返回None对象。

What can I do to resolve this problem? 我该怎么做才能解决这个问题? NOTE: When I executed cmake to build the binaries for Open CV 3.1 on Raspberry Pi, I havent specified OpenCV to use V4L. 注意:当我执行cmake在Raspberry Pi上为Open CV 3.1生成二进制文件时,我没有指定OpenCV使用V4L。 Could this be a problem? 这可能是个问题吗?

Thanks in advance. 提前致谢。

It's Because your video stream object does not get attached with the camera. 这是因为您的视频流对象没有与摄像机连接。 Hence no image is displayed. 因此,没有图像显示。 If you are using Pi Camera, then make sure to type --picamera 1 as an argument while running the script. 如果您使用的是Pi Camera,请确保在运行脚本时键入--picamera 1作为参数。 else your camera is not connected to your Pi correctly. 否则您的相机未正确连接到Pi。

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

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