我关注了这个网站
(https://www.pyimagesearch.com/2015/03/30/accessing-the-raspberry-pi-camera-with-opencv-and-python/ https://www.pyimagesearch.com/2015/03/30/accessing-the-raspberry-pi-camera-with-opencv-and-python/)来设置我的 picamera,但我的 picamera 模块有问题。我确实安装了picamera模块,这张图片来自pip freeze。
https://i.stack.imgur.com/Jpqtr.jpg https://i.stack.imgur.com/Jpqtr.jpg
您可以看到我已经有了 picamera 1.13,但是当我尝试 test_image.py 时,它显示“没有名为‘picamera’的模块”。
https://i.stack.imgur.com/oEwPB.jpg https://i.stack.imgur.com/oEwPB.jpg
我已经卸载并安装了很多次,但错误仍然存在。我该如何解决?
test_image.py
# import the necessary packages
from picamera.array import PiRGBArray
from picamera import PiCamera
import time
import cv2
# initialize the camera and grab a reference to the raw camera capture
camera = PiCamera()
rawCapture = PiRGBArray(camera)
# allow the camera to warmup
time.sleep(0.1)
# grab an image from the camera
camera.capture(rawCapture, format="bgr")
image = rawCapture.array
# display the image on screen and wait for a keypress
cv2.imshow("Image", image)
cv2.waitKey(0)
对于 python3,您必须尝试下面的命令。请记住,您需要在主目录中打开终端。
sudo -H apt install python3-picamera
sudo -H pip3 install --upgrade picamera[array]
让我知道它是否有效!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)