你好。我需要从连接到 python 覆盆子的 USB 相机获取照片。但事实是 PiCamera 标准库看不到相机,尽管它连接正确,我什至设法使用 luvcview 从中获取图像。问题是什么?追溯:
Traceback (most recent call last):
File "/home/pi/Desktop/cammm.py", line 4, in <module>
camera = picamera.PiCamera()
File "/usr/local/lib/python2.7/dist-packages/picamera/camera.py", line 431,
in __init__
self._init_camera(camera_num, stereo_mode, stereo_decimate)
File "/usr/local/lib/python2.7/dist-packages/picamera/camera.py", line 460,
in _init_camera
"Camera is not enabled. Try running 'sudo raspi-config' "
picamera.exc.PiCameraError: Camera is not enabled. Try running 'sudo raspi-
config' and ensure that the camera has been enabled.
编码:
from time import sleep
from picamera import PiCamera
camera = picamera.PiCamera()
camera.resolution = (1024, 768)
camera.start_preview()
# Camera warm-up time
sleep(2)
camera.capture('foo.jpg')
您可以尝试使用 pygame 捕获图像: