I had to append " -lwiringPi" to host_applications/linux/apps/raspicam/CMakeFiles/raspiraw.dir/link.txt under release directory.
Now I need to compile userland raspivid with wiringPi library, but I cannot figure out the file for adding "-lwiringPi" and getting "./buildme" succeed. Which file needs to be updated?
The modifications I want to do are just 3 lines:
- #include <wiringPi.h>
- wiringPiSetupGpio(); at start of main()
- fprintf(pData->pts_file_handle,"%lld.%03lld\n", pts/1000, pts%1000);
+ fprintf(pData->pts_file_handle,"%lld.%03lld %d\n", pts/1000, pts%1000, pwmRead(18));
In order to synchronize recordings of cameras of two Pis.
I connect GPIO18 of Pis together, as well as GND.
On first Pi I do:
gpio -g mode 18 IN
On second Pi I do:
gpio -g mode 18 OUT
gpio -g write 18 0
Then I start raspivid recordings with same framerate on both Pis.
Finally on 2nd Pi I turn on 1Hz PWM:
gpio -g mode 18 pwm
gpio -g pwm-ms
gpio -g pwmc 1000
gpio -g pwmr 19200
gpio -g pwm 18 9600
The timestamps file 2nd column will start with lots of 0s, and then show pattern of 1s and 0s with 1Hz frequency and 50% duty cycle. This will allow to synchronize both Pi's video timestamps nearly exactly.
I did test already that "gpio -g read 18" or "pwmRead(18)" do work fine on 2nd Pi that generates the PWM signal (and of course on first Pi with mode IN on GPIO18).
Finally "mkvmerge" tool will generate .mkv videos that can be further processed with ffmpeg to cut out parts of each video that are in absolute sync (eg. for 3D vision).