1

I am using python to preview and capture images with a Raspberry Pi and the picamera library.

I am using the following code:

import picamera
import RPi.GPIO as GPIO
import time
import datetime

button_pin = 15
save_path = 'save-folder/'

GPIO.setmode(GPIO.BCM)
GPIO.setup(button_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

with picamera.PiCamera() as camera:
    camera.resolution = (1920, 1080)
    camera.framerate = 15
    camera.sensor_mode = 2
    camera.rotation = 180
    camera.start_preview()

    while True:
        camera.start_preview()

        # wait for user to push button
        GPIO.wait_for_edge(button_pin, GPIO.RISING)
        filename = datetime.datetime.now().strftime("%Y-%m-%d_%H%M%S_img")
    
        camera.capture(save_path + filename + '.png')

After the line camera.capture(save_path + filename + '.png') the captured image will be previewed for 3 seconds and after that the live camera preview is back. Is it possible to show the live preview directly after the image is captured without displaying the captured image?

Thank you for your help.

Simon

  • Use open-cv module. You can directly save to file to a location with any porblems in that – AKD Mar 26 '21 at 06:04

0 Answers0