I have external sensor conected to GPIO, i must see on display one frame from camera when sensor is active.
All new frames must raplace old frames. Frequency expected from the sensor is about 10 Hz.
Any idea?
Now i trying simply capture the frame and show it:
Code: Select all
import RPi.GPIO as GPIO
import time
import picamera
import picamera.array
from PIL import Image
pin=2 # sensor pin
GPIO.setmode(GPIO.BCM)
GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
with picamera.PiCamera() as camera:
with picamera.array.PiRGBArray(camera) as stream:
camera.resolution = (1280, 720)
camera.iso = 800
camera.awb_mode = 'auto'
camera.framerate = 30
time.sleep(2)
while True:
camera.capture(stream, 'rgb', use_video_port=True)
stream.seek(0)
img = Image.fromarray(stream.array, 'RGB')
img.show()
GPIO.wait_for_edge(pin, GPIO.RISING)
Can i use preview for my target?