Hello everyone,
I've been working on a project involving two Raspberry Pi global shutters cameras connected to a Raspberry Pi 5, using an external trigger signal provided by a Raspberry Pico. The task is to synchronously capture images by two cameras.
I followed the steps outlined in this documentation page:
https://github.com/raspberrypi/document ... igger.adoc
In my MicroPython code, I adjusted the framerate to 60 and the shutter speed to 10000.
Then I made experimental setup with 10 LEDs arranged in a line, creating "traveling wave" effect: each LED stays turn on for exact period of time (e.g. 10 milliseconds) after it is turn off and the next neighbor LED lights up, and so on. The flash period for each LED was set to 10 milliseconds.
Next, I executed the MicroPython code from the external trigger documentation on the Raspberry Pi Pico. Following that, I ran a Python script:
got:
and
I got two saved images and they are different - two cameras captured images at slightly different times.
![Image]()
![Image]()
Additionally, when I captured images using the 'libcamera-still' command, I observed similar discrepancies between the images from the two cameras.
Why the cameras are not capturing synchronized images?I would appreciate any insights or suggestions on how to resolve this issue.
Thanks in advance for your help!
I've been working on a project involving two Raspberry Pi global shutters cameras connected to a Raspberry Pi 5, using an external trigger signal provided by a Raspberry Pico. The task is to synchronously capture images by two cameras.
I followed the steps outlined in this documentation page:
https://github.com/raspberrypi/document ... igger.adoc
In my MicroPython code, I adjusted the framerate to 60 and the shutter speed to 10000.
Then I made experimental setup with 10 LEDs arranged in a line, creating "traveling wave" effect: each LED stays turn on for exact period of time (e.g. 10 milliseconds) after it is turn off and the next neighbor LED lights up, and so on. The flash period for each LED was set to 10 milliseconds.
Next, I executed the MicroPython code from the external trigger documentation on the Raspberry Pi Pico. Following that, I ran a Python script:
Code:
from picamera2 import Picamera2, Previewimport threadingimport timedef thread_func(num, picam): last_timestamp = picam.capture_metadata()["SensorTimestamp"] while True: meta = picam.capture_metadata() timestamp, frame_dur, exposure_t = meta["SensorTimestamp"], meta['FrameDuration'], meta['ExposureTime'] timestamp, last_timestamp = timestamp - last_timestamp, timestamp print(f"cam_num: {num}, diff sensor timestamp: {timestamp / 1000000}, frame duration: {frame_dur}, exposure: {exposure_t}") def start_picam2(num): picam = Picamera2(num) config = picam.create_preview_configuration(controls={'FrameRate': 60, 'ExposureTime': 10000}) picam.start(config) return picam picams = [start_picam2(i) for i in range(2)]threads = [threading.Thread(target=thread_func, args=args) for args in enumerate(picams)]for thread in threads: thread.start()
got:
Code:
>>cam_num: 0, diff sensor timestamp: 16.652, frame duration: 16666, exposure: 9999>>cam_num: 0, diff sensor timestamp: 16.651, frame duration: 16666, exposure: 9999>>cam_num: 0, diff sensor timestamp: 16.652, frame duration: 16666, exposure: 9999>>cam_num: 0, diff sensor timestamp: 16.652, frame duration: 16666, exposure: 9999>>cam_num: 1, diff sensor timestamp: 16.652, frame duration: 16666, exposure: 9999>>cam_num: 0, diff sensor timestamp: 16.653, frame duration: 16666, exposure: 9999>>cam_num: 1, diff sensor timestamp: 16.659, frame duration: 16666, exposure: 9999>>cam_num: 0, diff sensor timestamp: 16.652, frame duration: 16666, exposure: 9999>>cam_num: 1, diff sensor timestamp: 16.645, frame duration: 16666, exposure: 9999>>cam_num: 0, diff sensor timestamp: 16.652, frame duration: 16666, exposure: 9999>>cam_num: 1, diff sensor timestamp: 16.653, frame duration: 16666, exposure: 9999...
Code:
def thread_func(num, picam): time.sleep(2) picam.capture_file(f"/home/pc/Documents/trigTwoGS/thread_image{num}.jpg") def start_picam2(num): picam = Picamera2(num) config = picam.create_preview_configuration(controls={'FrameRate': 60, 'ExposureTime': 10000}) picam.start(config) return picam picams = [start_picam2(i) for i in range(2)]threads = [threading.Thread(target=thread_func, args=args) for args in enumerate(picams)]for thread in threads: thread.start()
I got two saved images and they are different - two cameras captured images at slightly different times.


Additionally, when I captured images using the 'libcamera-still' command, I observed similar discrepancies between the images from the two cameras.
Code:
libcamera-still --camera 0 --output /home/pc/Documents/trigTwoGS/im_cam0.jpg --shutter 10000 --framerate 60 & libcamera-still --camera 1 --output /home/pc/Documents/trigTwoGS/im_cam1.jpg --shutter 10000 --framerate 60
Thanks in advance for your help!
Statistics: Posted by Raccoon987 — Sat Mar 23, 2024 9:38 pm — Replies 1 — Views 47