i am very satisfied with the results thanks for your comments and your great tools u develop
i used that on rasbery pi 3b+
i will try to test with a second camera on raspberry pi5 .
how to use 2 camera with this code ? . will it be around 1 sec .
i will capture some book pages and i will upload them here asking more question about .
i used this with gpio
results
and with keyboard
results i think is slightly slower
i used that on rasbery pi 3b+
i will try to test with a second camera on raspberry pi5 .
how to use 2 camera with this code ? . will it be around 1 sec .
i will capture some book pages and i will upload them here asking more question about .
i used this with gpio
Code:
import RPi.GPIO as GPIOfrom picamera2 import Picamera2import timefrom datetime import datetime# Set up GPIO 18 as an input with pull-upGPIO.setmode(GPIO.BCM)GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)picam2 = Picamera2()config = picam2.create_still_configuration(buffer_count=1)picam2.configure(config)picam2.start()try: while True: # Wait for GPIO 18 to go low while GPIO.input(18): time.sleep(0.1) # Record the start time start_time = time.time() # When GPIO 18 goes low, capture an image timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") filename = f"file_{timestamp}.jpg" request = picam2.capture_request(flush=True) request.save('main', filename) request.release() # Record the end time end_time = time.time() # Calculate and print the time taken capture_time = end_time - start_time print(f"Image captured: {filename}, Time taken: {capture_time:.2f} seconds") # Wait for GPIO 18 to go high again (to prevent multiple captures on a single press) while not GPIO.input(18): time.sleep(0.1)except KeyboardInterrupt: passfinally: # Clean up GPIO GPIO.cleanup() picam2.stop()
Code:
[1:26:37.145669248] [3223] INFO Camera camera_manager.cpp:284 libcamera v0.1.0+118-563cd78e[1:26:37.311021339] [3229] WARN RPiSdn sdn.cpp:39 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise[1:26:37.317354895] [3229] INFO RPI vc4.cpp:444 Registered camera /base/soc/i2c0mux/i2c@1/imx708@1a to Unicam device /dev/media3 and ISP device /dev/media0[1:26:37.317603540] [3229] INFO RPI pipeline_base.cpp:1142 Using configuration file '/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml'[1:26:37.327167389] [3223] INFO Camera camera_manager.cpp:284 libcamera v0.1.0+118-563cd78e[1:26:37.427623251] [3232] WARN RPiSdn sdn.cpp:39 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise[1:26:37.433518476] [3232] INFO RPI vc4.cpp:444 Registered camera /base/soc/i2c0mux/i2c@1/imx708@1a to Unicam device /dev/media3 and ISP device /dev/media0[1:26:37.433667329] [3232] INFO RPI pipeline_base.cpp:1142 Using configuration file '/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml'[1:26:37.452664456] [3223] INFO Camera camera.cpp:1183 configuring streams: (0) 4608x2592-BGR888 (1) 4608x2592-SBGGR10_CSI2P[1:26:37.453633356] [3232] INFO RPI vc4.cpp:608 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 4608x2592-SBGGR10_1X10 - Selected unicam format: 4608x2592-pBAAImage captured: file_20240118_043222.jpg, Time taken: 1.06 secondsImage captured: file_20240118_043224.jpg, Time taken: 1.09 secondsImage captured: file_20240118_043226.jpg, Time taken: 0.95 seconds
Code:
import keyboardfrom picamera2 import Picamera2import timefrom datetime import datetimepicam2 = Picamera2()config = picam2.create_still_configuration(buffer_count=1)picam2.configure(config)picam2.start()try: while True: # Wait for the space key to be pressed keyboard.wait("space") # Record the start time start_time = time.time() # Capture an image timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") filename = f"file_{timestamp}.jpg" request = picam2.capture_request(flush=True) request.save('main', filename) request.release() # Record the end time end_time = time.time() # Calculate and print the time taken capture_time = end_time - start_time print(f"Image captured: {filename}, Time taken: {capture_time:.2f} seconds")except KeyboardInterrupt: passfinally: # Clean up picam2.stop()
results i think is slightly slower
Code:
[1:37:27.046278964] [3437] INFO Camera camera_manager.cpp:284 libcamera v0.1.0+118-563cd78e[1:37:27.146640856] [3443] WARN RPiSdn sdn.cpp:39 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise[1:37:27.152654707] [3443] INFO RPI vc4.cpp:444 Registered camera /base/soc/i2c0mux/i2c@1/imx708@1a to Unicam device /dev/media3 and ISP device /dev/media0[1:37:27.152879340] [3443] INFO RPI pipeline_base.cpp:1142 Using configuration file '/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml'[1:37:27.159286677] [3437] INFO Camera camera_manager.cpp:284 libcamera v0.1.0+118-563cd78e[1:37:27.256174174] [3446] WARN RPiSdn sdn.cpp:39 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise[1:37:27.261940892] [3446] INFO RPI vc4.cpp:444 Registered camera /base/soc/i2c0mux/i2c@1/imx708@1a to Unicam device /dev/media3 and ISP device /dev/media0[1:37:27.262091672] [3446] INFO RPI pipeline_base.cpp:1142 Using configuration file '/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml'[1:37:27.280776448] [3437] INFO Camera camera.cpp:1183 configuring streams: (0) 4608x2592-BGR888 (1) 4608x2592-SBGGR10_CSI2P[1:37:27.281792376] [3446] INFO RPI vc4.cpp:608 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 4608x2592-SBGGR10_1X10 - Selected unicam format: 4608x2592-pBAA Image captured: file_20240118_044312.jpg, Time taken: 1.88 seconds Image captured: file_20240118_044315.jpg, Time taken: 1.12 seconds Image captured: file_20240118_044317.jpg, Time taken: 1.01 seconds Image captured: file_20240118_044318.jpg, Time taken: 1.05 seconds
Statistics: Posted by Konos93a — Thu Jan 18, 2024 3:01 am