Python Raspberry Pi OpenCV和USB cam

时间:2018-04-22 16:15:58

标签: python opencv raspberry-pi

我有Raspberry Pi 3,安装的操作系统是Raspbian Jessie。我试图访问我的USB网络摄像头,因为我没有覆盆子相机模块。这是我的代码:

import cv2

# initialize the camera
cam = cv2.VideoCapture(0)
ret, image = cam.read()

if ret:
    cv2.imshow('SnapshotTest',image)
    cv2.waitKey(0)
    cv2.destroyWindow('SnapshotTest')
    cv2.imwrite('/home/pi/book/output/SnapshotTest.jpg',image)
cam.release()

但我唯一能看到的就是灰屏。我必须做什么?谢谢你的帮助

它提出了这个输出:

  

Xlib:扩展' RANDR'缺少展出":1.0"。

0 个答案:

没有答案