[英]How to freeze picamera preview
I want to start a camera preview which takes a picture after some time using the PiCamera Module, and when the picture was taken it should frezze the preview so the user can view it, how can i freeze the preview? 我想开始使用PiCamera模块在一段时间后开始拍照的相机预览,并且在拍照后应使预览微缩,以便用户查看,我如何冻结预览?
Currently I display it using matplotlib.image: 目前,我使用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)
有多种方法可以执行此操作,但是您可以使用
plt.waitforbuttonpress()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.