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

Re: Cheapest High speed camera up to 900 FPS!!

Fri Dec 15, 2017 3:12 am

The highest framerate that can be achieved for capturing 640x128 stretched frames is 665fps!
Here is a sample frame, dcraw processed and converted to .png:
Image

Half an hour ago I asked myself how fast 640x64 can be captured.
I was even able to capture with 1000fps(!), but interleaved with many frame skips.

So I did what this thread is about, capturing with 900fps, looks still coloful for 1000/900=1.1ms shutter time:
Image

Now frame skip and delta distribution analysis are possible, I captured 7171 frames in 8s with Pi 2B and v1 camera:

Code: Select all

$ rm /dev/shm/out.*.raw
$ raspiraw -md 7 -t 8000 -ts tstamps.csv -hd0 hd0.raw -h 32 --vinc 1F --fps 900 -r "380A,0020;3802,78;3806,05DF" -sr 1 -o /dev/shm/out.%04d.raw 2>/dev/null
Using i2C device /dev/i2c-0
$ ls -l /dev/shm/out.*.raw | wc --lines
7171
$ 

Although 7171 frames got captured in 8s, /dev/shm is filled <50%. So you can capture 16s of 900fps video!

Code: Select all

$ df /dev/shm
Filesystem     1K-blocks   Used Available Use% Mounted on
tmpfs             448396 202888    245508  46% /dev/shm
$ 

Timestamp analysis can be done from tstamps.csv generated by above command line:

Code: Select all

$ cut -f1 -d, tstamps.csv | sort -n | uniq -c
      1 
      4 1097
      3 1098
      3 1099
   2825 1100
   4228 1101
      4 1102
      2 1103
      4 1104
      1 2200
     73 2201
     22 2202
      1 2203
$ 

So the frame delta time is 1101us ± 4us (908.2fps), with 1+73+22+1=97 frame skips.

Code: Select all

$ bc -ql
1000000/1101
908.26521344232515894641

This allows to find a longer range without skips:

Code: Select all

$ grep "^2" tstamps.csv 
2200,2,26521736979
...
2201,77,26521847039
2201,921,26522777046
2201,2801,26524847274
2201,4699,26526937313
2201,6484,26528902984
...
2201,6600,26529104394
$ 

There are no frame skips for 1898 frames in range 2801-4698.
This is how above 640x64 frame was generated from raw Bayer:

Code: Select all

$ cat hd0.raw /dev/shm/out.3000.raw >out.3000.raw
$ dcraw out.3000.raw 
$ double out.3000.ppm > out.3000.ppm.d
$ pnmtopng out.3000.ppm.d > out.3000.ppm.d.png
$ 

github repo contains lot of documentation, and tools to automatically create .ogg video and animated .gif from a given set of frames. You can see some animated .gifs created that way above in this thread.


P.S:
Even if taking the frame skips into account, the average framerate is still 896fps!

Code: Select all

$ echo "1000000/(((7171-97)*1101+97*2201)/7171)" | bc -ql
896.15421000650964618592
$ 

The timestamp file can be converted into a Matroska format. That allows to create a .mkv Matroska video from the .ogg video, where each frame gets exactly played at the correct timestamp. With such a .mkv video the frame skips can be neglected.
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

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

Re: Cheapest High speed camera up to 900 FPS!!

Wed Apr 25, 2018 7:19 pm

What I showed before was 640x32 video at 896fps average framerate with (5$) v1 camera.

Here you find details of 640x75 video at 1005fps average framerate with (25$) v2 camera
(more than double framesize, and above 1000fps, played at 30fps, 33.5 times slower than real):
viewtopic.php?f=43&t=109137&p=1307795#p1307795
Image
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

larapnr
Posts: 10
Joined: Wed Oct 24, 2018 7:02 am

Re: Cheapest High speed camera up to 900 FPS!!

Thu Oct 25, 2018 7:37 am

HermannSW wrote:
Fri Dec 15, 2017 3:12 am
The highest framerate that can be achieved for capturing 640x128 stretched frames is 665fps!
Here is a sample frame, dcraw processed and converted to .png:
Image

Half an hour ago I asked myself how fast 640x64 can be captured.
I was even able to capture with 1000fps(!), but interleaved with many frame skips.

So I did what this thread is about, capturing with 900fps, looks still coloful for 1000/900=1.1ms shutter time:
Image

Now frame skip and delta distribution analysis are possible, I captured 7171 frames in 8s with Pi 2B and v1 camera:

Code: Select all

$ rm /dev/shm/out.*.raw
$ raspiraw -md 7 -t 8000 -ts tstamps.csv -hd0 hd0.raw -h 32 --vinc 1F --fps 900 -r "380A,0020;3802,78;3806,05DF" -sr 1 -o /dev/shm/out.%04d.raw 2>/dev/null
Using i2C device /dev/i2c-0
$ ls -l /dev/shm/out.*.raw | wc --lines
7171
$ 

Although 7171 frames got captured in 8s, /dev/shm is filled <50%. So you can capture 16s of 900fps video!

Code: Select all

$ df /dev/shm
Filesystem     1K-blocks   Used Available Use% Mounted on
tmpfs             448396 202888    245508  46% /dev/shm
$ 

Timestamp analysis can be done from tstamps.csv generated by above command line:

Code: Select all

$ cut -f1 -d, tstamps.csv | sort -n | uniq -c
      1 
      4 1097
      3 1098
      3 1099
   2825 1100
   4228 1101
      4 1102
      2 1103
      4 1104
      1 2200
     73 2201
     22 2202
      1 2203
$ 

So the frame delta time is 1101us ± 4us (908.2fps), with 1+73+22+1=97 frame skips.

Code: Select all

$ bc -ql
1000000/1101
908.26521344232515894641

This allows to find a longer range without skips:

Code: Select all

$ grep "^2" tstamps.csv 
2200,2,26521736979
...
2201,77,26521847039
2201,921,26522777046
2201,2801,26524847274
2201,4699,26526937313
2201,6484,26528902984
...
2201,6600,26529104394
$ 

There are no frame skips for 1898 frames in range 2801-4698.
This is how above 640x64 frame was generated from raw Bayer:

Code: Select all

$ cat hd0.raw /dev/shm/out.3000.raw >out.3000.raw
$ dcraw out.3000.raw 
$ double out.3000.ppm > out.3000.ppm.d
$ pnmtopng out.3000.ppm.d > out.3000.ppm.d.png
$ 

github repo contains lot of documentation, and tools to automatically create .ogg video and animated .gif from a given set of frames. You can see some animated .gifs created that way above in this thread.


P.S:
Even if taking the frame skips into account, the average framerate is still 896fps!

Code: Select all

$ echo "1000000/(((7171-97)*1101+97*2201)/7171)" | bc -ql
896.15421000650964618592
$ 

The timestamp file can be converted into a Matroska format. That allows to create a .mkv Matroska video from the .ogg video, where each frame gets exactly played at the correct timestamp. With such a .mkv video the frame skips can be neglected.
Hi Hermann,

i tried your codes because for a project in our firm I needed de maximum frame rate on the raspi cam possible.
But actually, the programm just gave me many failure messages and none of it worked :(.
I'm a beginner in programming, but I've looked everywhere and cannot find a solution to my problem.
Could you help me with this?
what do I need for the software, devices etc. to make this work?
I have the raspberry pi 3, camera modul v2, a SD Card with 32gb storage and a normal raspberry screen.
Thank you very much

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

Re: Cheapest High speed camera up to 900 FPS!!

Sat Oct 27, 2018 7:15 pm

Hi,

the program to use for framerates >200fps is raspiraw.
You find instructions on how to build and install in 1a here:
https://stamm-wilbrandt.de/en/Raspberry ... l#raspiraw

You need 6by9's dcraw for post processing the raw bayer frames:
https://github.com/6by9/dcraw
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

Return to “General discussion”