David Ford
Posts: 13
Joined: Wed Sep 26, 2018 10:01 pm

Firing 3-4 cameras at the exact same time

Sun Dec 02, 2018 6:40 am

I have an application where I want to be able to fire 3-4 pi cameras at exactly (or very nearly exactly, like low ms range) the same time with my Pi and perhaps two linked Pi Zeros. They will be in very close proximity (inches) so physical wiring between them is assumed.

My concern is latency between command and firing, even if using an interrupt.

Another concern is image storage/processing time between a 3B+ and a Zero W. will the 3B+ need to wait for the daughter boards to catch up. I'm not talking about taking multiple shots per second or anything. 5 seconds between shots could suffice, maybe more. How would the mother unit know when the daughter units are freed up? This might be a moot point if I space the photos out appropriately.

Also, what is advisability of hooking the two daughter boards to the same pin outs on the mother unit?

What all non-essential modules could I remove from the Rasbian OS to minimize or eliminate the possibility of some unwanted process taking resources when I'd like the boards focusing on the photography?

TIA.

PhatFil
Posts: 614
Joined: Thu Apr 13, 2017 3:55 pm

Re: Firing 3-4 cameras at the exact same time

Sun Dec 02, 2018 7:25 am

I would suggest testing to find out if latency is an issue at all. hooking all the 'daughters' input gpio pins to the 'Mothers' output gpio pin used to trigger the photography shouldn't be a problem, your not going to draw a significant load. and as for the non time critical "Im ready" signals from the daughters i would suggest using a wifi protocol like mqtt to signal the mother would be fine..

in fact if you have all pi puters synced to the same time at the start of the photography session and issue take photograph commands with a specific time embedded i suspect you could issue the take picture commands wirelessly via mqtt too.

Until you 'suck it n see' it will remain a conceptual problem, start testing and you may not reveal any gotchas, but if you do then you can address them 1 by 1..

HermannSW
Posts: 830
Joined: Fri Jul 22, 2016 9:09 pm

Re: Firing 3-4 cameras at the exact same time

Sun Dec 02, 2018 9:26 am

For calibration of "exact same time" picture taking you need something that changes very quickly.
Even expensive smartphone ms timers cheat in updating display only every 8ms or so (I tested IPhone of a colleague).
Some displays are just too slow to display fast.
And then software needs some time as well for the display updates.

I once created a "special" Raspbberry clock directly writing into top left of 7" display framebuffer.
That clock does 5000 updates/second on Pi 3B+.
Here is short video, recorded with raspivid and v2 camera at 180fps, played at 25fps, 7.2 times slower than real.
The description contains link to the short and simple code (not nice):
https://www.youtube.com/watch?v=K0XK2BrqWhw
Image


For calibration I would direct all your cameras to top left of display and get sharp image with correct lenses (the clock is only 8x11 pixel for allowing high update rate). Then try out whatever notification mechanism you want (I would go with GPIO pins for "exact same time") and check whether the images show same timestamp (100s, 10s and 1s in top three rows, 1/10s, 1/100s and 1ms in bottow three rows). If not you can even determine the latency from the timestamps of the two images.

P.S:
Of course the ms resolution clock Pi needs to do nothing else than running the clock.
I have not tested Pi Zero, is probably good enough for this task.
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/fork-raspiraw      https://github.com/Hermann-SW/userland
https://github.com/Hermann-SW/wireless-control-Eachine-E52-drone      https://twitter.com/HermannSW

ethanol100
Posts: 542
Joined: Wed Oct 02, 2013 12:28 pm

Re: Firing 3-4 cameras at the exact same time

Sun Dec 02, 2018 12:53 pm

I tried the following procedure to get best in sync between cameras:

I added wiringPi to raspistill and basically wait for 2 key presses. I start raspistill on all pis and the first interrupt will wait just before "bcm_host_init();" to initialize the cameras at around the same time. Then I added a wait method which uses the same button to register an interrupt as wait function. The second/third/.... gpio pulse will take a capture, which is in sync. The gpios are pull downs which can be easily put in parallel to trigger several cameras. You can additional use the sync pulses to register the times, when images are received from the camera, to check for the quality of synchronization. I used an arduino to log the picture times of all Pis.

David Ford
Posts: 13
Joined: Wed Sep 26, 2018 10:01 pm

Re: Firing 3-4 cameras at the exact same time

Thu Dec 06, 2018 2:48 pm

Thanks all.

HermannSW
Posts: 830
Joined: Fri Jul 22, 2016 9:09 pm

Re: Firing 3-4 cameras at the exact same time

Thu Dec 06, 2018 7:28 pm

I just compiled td.c from youtube video description link:
https://stamm-wilbrandt.de/en/youtube/td.c

This time I did run it on RHEL Linux i7 laptop.
I cannot see visual updates on top left corner of X11, nor anywhere else on X11.
But the clock updates/second are much better (16967):

Code: Select all

$ sudo ./td
12873
19460
25384
25789
44098
44565
44974
47197
48568
49300
50836
51415
51564
55588
58935
^C
$ 
But that does not help without clock being visible on X11, will try to find out how to make visible framebuffer updates under RHEL X11.

P.S:
I did switch to ascii console window -- there the changes in framebuffer really show up (which is all that is needed for super fast clock).
I just need to get the offsets right ...
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/fork-raspiraw      https://github.com/Hermann-SW/userland
https://github.com/Hermann-SW/wireless-control-Eachine-E52-drone      https://twitter.com/HermannSW

HermannSW
Posts: 830
Joined: Fri Jul 22, 2016 9:09 pm

Re: Firing 3-4 cameras at the exact same time

Thu Dec 06, 2018 8:50 pm

Framebuffer is 1920x1080 bgr_, visible part is top left 1680x1050 (FLATRON W2242T 60Hz monitor).

How to build and use:
  1. download td.c
  2. sed "s/1024/1920/g" td.c > FHD_clk.c
  3. gcc -O6 FHD_clk.c -o FHD_clk
  4. switch from X11 to one of the ASCII consoles, eg. CTRL+ALT+F2
  5. sudo ./FHD_clk
Better would be to have monitor with higher refresh than 60Hz.

Image
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/fork-raspiraw      https://github.com/Hermann-SW/userland
https://github.com/Hermann-SW/wireless-control-Eachine-E52-drone      https://twitter.com/HermannSW

HermannSW
Posts: 830
Joined: Fri Jul 22, 2016 9:09 pm

Re: Firing 3-4 cameras at the exact same time

Fri Dec 07, 2018 9:23 pm

Neither solution helps with millisecond resolution, even the best monitors have "only" 240Hz.

Today I built a millisecond resolution laser clock from 5 laser leds.
I used an Arduino Due to drive the clock, will later do with Pi Zero as well.

"Millisecond resolution laser clock"
https://forum.arduino.cc/index.php?topic=583905.0

This is is 1007fps 640x150_s video captured with raspiraw and Raspberry v2 camera, played at 1fps.
Image


For details see above thread, only feature I want to mention here is that the clock can easily do 0.1ms resolution as well !
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/fork-raspiraw      https://github.com/Hermann-SW/userland
https://github.com/Hermann-SW/wireless-control-Eachine-E52-drone      https://twitter.com/HermannSW

Return to “Camera board”