我想开始使用PiCamera模块在一段时间后开始拍照的相机预览,并且在拍照后应使预览微缩,以便用户查看,该如何冻结预览?
当前,我使用matplotlib.image显示它:
from picamera import PiCamera
from time import sleep
import RPi.GPIO as GPIO
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
def btn_press(channel):
camera.start_preview()
camera.annotate_text="3..."
sleep(1)
camera.annotate_text="2..."
sleep(1)
camera.annotate_text="1..."
sleep(1)
camera.capture("image.jpg")
camera.annotate_text="Pic taken"
sleep(5)
camera.stop_preview()
pic=mpimg.imread("image.jpg")
plt.imshow(pic)
plt.show()
#print("pic taken")
camera = PiCamera()
camera.led=False
camera.annotate_text_size=100
btn=20
GPIO.setmode(GPIO.BCM)
GPIO.setup(20, GPIO.IN)
GPIO.add_event_detect(btn, GPIO.BOTH, callback=btn_press, bouncetime=8000)
答案 0 :(得分:0)
执行此操作的方法有多种,但您可以使用
plt.waitforbuttonpress()