简体   繁体   中英

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. I have tried to capture frames with this simple tutorial code on

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:

NoneType object has no attribute 'shape'

I have printed out the vs.read() function and it also returns None object.

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. 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. else your camera is not connected to your Pi correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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