JustNoOne
Posts: 1
Joined: Sun Mar 25, 2018 2:41 pm

Maximum capture speed

Sun Mar 25, 2018 2:46 pm

I am wondering what is the raspberry pi camera v2's maximum frame capture speed. I am using it on pi3 model B. I used python picamera library and I get maximum 2 fps (640x480). I get 20-30 fps when I activated the video port. However, it decreases the angle of camera.

My question is that what is the maximum fps that I can get without using video_port?

User avatar
HermannSW
Posts: 1657
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Maximum capture speed

Mon Mar 26, 2018 8:02 am

I don't use picamera and don't know why it is so slow.

With latest Raspbian Stretch raspivid can not only capture 640x480 at 90fps, but at 150fps ...
viewtopic.php?f=66&t=209041

... and even at 180fps:
viewtopic.php?f=43&t=206047&p=1285069#p1285069

And the not so quickly passing parts are sharp even at 180fps
(180fps video frame taken from train passing train station/foot bridge at roughly 100km/h):
Image
⇨https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/github_repo_i420toh264
https://github.com/Hermann-SW/fork-raspiraw
https://twitter.com/HermannSW

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7560
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Maximum capture speed

Mon Mar 26, 2018 9:15 am

JustNoOne wrote:
Sun Mar 25, 2018 2:46 pm
I am wondering what is the raspberry pi camera v2's maximum frame capture speed. I am using it on pi3 model B. I used python picamera library and I get maximum 2 fps (640x480). I get 20-30 fps when I activated the video port. However, it decreases the angle of camera.

My question is that what is the maximum fps that I can get without using video_port?
You can potentially get more if you set burst mode (absolute max 15fps as the sensor is set to full resolution), but otherwise a few fps is the best you will get from the stills port due to the mode switching.

If the video port is giving a different mode due to the automatic mode choice getting it wrong, you can override that using sensor_mode property. See https://picamera.readthedocs.io/en/late ... nsor-modes for the choices.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

ncam07
Posts: 1
Joined: Wed Mar 21, 2018 10:48 am

Re: Maximum capture speed

Thu Mar 29, 2018 11:51 am

Hi,

From the docs , the new sensor has partial fov for higher fps ..if you are trying to capture a video then there are some work around to get higher frame rates with picamera . But if you are capturing raw images to process i think picamera is not the right api which can give high framerates ..i am not sure what is the bug here. If you work with apis provided by raspberry pi foundation or there are some other api wrappers using which with video port you should be able to capture more that 90 frames per second.

fishbeetle
Posts: 6
Joined: Tue Apr 03, 2018 4:26 pm

Re: Maximum capture speed

Tue Apr 03, 2018 4:46 pm

I've just hit this same speed-limit with v2 camera, RPi3B, Rasbian, fully up-to-date, PiCamera, Python3 maximum rate at which I can capture rgb stills in full 8Mpix resolution even with burst=True and using the video port is < 2 fps.
Code snippet:

camera = PiCamera(resolution=(3280,2464), framerate=15) # sensor_mode=3 only makes it worse
time.sleep(2)
cnt = 0
stream = BytesIO()
for _ in camera.capture_continuous(stream, burst=True, format='rgb'):
stream.truncate()
stream.seek(0)
print(time.time())
# DO NOTHING
cnt += 1
if cnt > 10: break
camera.close()

Produces:

1522773686.6025286
1522773687.146887
1522773687.8142288
1522773688.365152
1522773689.0265071
1522773689.5698907
1522773690.2124894
1522773690.7555723
1522773691.4342682
1522773691.9908934
1522773692.6525733

ie < 2fps. So disappointed.
Please let us all know if you find a way to increase the fps - I only need 5fps!
Thanks for listening.
Steve.

sneakers-the-rat
Posts: 1
Joined: Thu Oct 10, 2019 2:16 am

Re: Maximum capture speed

Thu Oct 10, 2019 2:29 am

This is an old thread, but came across it also looking for optimization tips.

You've got to think about what you're asking for...

If you're shooting 3280 x 2464 at 8-bits in RGB, each image is 24.25MB raw -- (3280x2464x8x3)/8

The theoretical limit of the camera bus is 100MBps per lane, so you're actually doing alright to be getting 2 fps.

take lower res images, take monochrome images, or buy a camera <3

User avatar
HermannSW
Posts: 1657
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Maximum capture speed

Fri Oct 11, 2019 1:44 am

I don't know where your calculation is wrong, but you can capture [email protected] without frameskips if you don't output to SD card.
raspivid does not allow to capture .h264 files with more than 1080 vertical resolution, so no option for 2464 lines.
But raspividyuv can easily capture 10s of 3280x2464 frames at 15fps into /dev/shm ramdisk:

Code: Select all

[email protected]:~ $ raspividyuv -md 2 -w 3280 -h 2464 -o /dev/shm/tst.yuv -pts tst.pts -t 10000 -fps 15
[email protected]:~ $ df /dev/shm
Filesystem     1K-blocks    Used Available Use% Mounted on
tmpfs            1908540 1784476    124064  94% /dev/shm
[email protected]:~ $
raspividyuv I420 format stores 12bit per pixel, 1.69GB for 150 of 3280x2464 frames:

Code: Select all

$ echo "scale=2; 3280*2464*1.5*150/(1024^3)" | bc -ql
1.69
$
Using
https://github.com/Hermann-SW/userland/ ... ptsanalyze
for frame delta and skip analysis shows that 15fps framerate can be achieved ...

Code: Select all

[email protected]:~ $ ptsanalyze tst.pts 0
creating tstamps.csv
150 frames were captured at 15fps
frame delta time[us] distribution
      2 66625
      1 66626
      1 66629
      2 66631
      1 66632
      1 66633
      3 66634
      3 66635
      1 66636
      1 66637
      2 66638
      1 66643
      1 66644
      1 66645
      1 66646
      1 66647
      3 66648
      3 66649
      3 66650
      5 66651
      2 66652
      1 66653
      9 66654
     13 66655
     19 66656
     15 66657
      7 66658
     10 66659
      5 66661
      3 66662
      2 66663
      3 66665
      3 66669
      1 66674
      1 66675
      1 66676
      3 66677
      3 66678
      3 66679
      2 66680
      1 66682
      1 66686
      1 66687
      1 66688
after skip frame indices (middle column)
0 frame skips (0%)
[email protected]:~ $ 
... with 0 frameskips:

Code: Select all

...
after skip frame indices (middle column)
0 frame skips (0%)
[email protected]:~ $ 

I typically use much smaller frame sizes (mostly 640x480 for >120fps framerates). I am really impressed of [email protected]

Because of the 1080p .h264 restriction 1640x1232 is no opton for raspivid either.
Now I see why v2 camera mode5 (1640x922) is interesting, allows to capture arbitrary length(!) .h264 video onto SD card:
https://www.raspberrypi.org/documentati ... /camera.md

Here is capture of 60s of [email protected] with output stored on SD card:

Code: Select all

[email protected]:~ $ raspivid -md 5 -w 1640 -h 922 -o tst.h264 -pts tst.pts -t 60000 -fps 40
[email protected]:~ $ du tst.h264 
63188	tst.h264
[email protected]:~ $
Analysis shows 40fps ...

Code: Select all

[email protected]:~ $ ptsanalyze tst.pts 0
creating tstamps.csv
2398 frames were captured at 40fps
frame delta time[us] distribution
      3 24985
      3 24986
     33 24987
     94 24988
    226 24989
    377 24990
    598 24991
    494 24992
    336 24993
    151 24994
     65 24995
     14 24996
      1 24997
after skip frame indices (middle column)
0 frame skips (0%)
[email protected]:~ $ 
... with 0 frame skips:

Code: Select all

...
after skip frame indices (middle column)
0 frame skips (0%)
[email protected]:~ $ 
⇨https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/github_repo_i420toh264
https://github.com/Hermann-SW/fork-raspiraw
https://twitter.com/HermannSW

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7560
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Maximum capture speed

Fri Oct 11, 2019 5:46 am

sneakers-the-rat wrote:
Thu Oct 10, 2019 2:29 am
This is an old thread, but came across it also looking for optimization tips.

You've got to think about what you're asking for...

If you're shooting 3280 x 2464 at 8-bits in RGB, each image is 24.25MB raw -- (3280x2464x8x3)/8
On the output, yes.
The theoretical limit of the camera bus is 100MBps per lane, so you're actually doing alright to be getting 2 fps.
Erm, no.
Csi2 supports up to 1Gbit/s per lane, and the Pi exposes two lanes. The cameras generally produce bayer data at 10bits per pixel. I make that 200MPix/s, or 25fps at 8MPix.
In practice the isp is limited at around 120MPix/s, which is where the 15fps max at 8MPix comes from.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
HermannSW
Posts: 1657
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Maximum capture speed

Fri Oct 11, 2019 9:25 am

6by9 wrote:
Fri Oct 11, 2019 5:46 am
Csi2 supports up to 1Gbit/s per lane, and the Pi exposes two lanes. The cameras generally produce bayer data at 10bits per pixel. I make that 200MPix/s, ...
It is 231.22Mbits per frame:

Code: Select all

$ echo "scale=2; 3280*2464*3*10/(1024^2)" | bc -ql
231.22
$ 
... or 25fps at 8MPix.
I must be doing something wrong, but two 1Gbps lanes allow for 8.85 frames only, although 25fps have been proven?

Code: Select all

$ echo "scale=2; 2*(1024^3)/(3280*2464*3*10)" | bc -ql
8.85
$ 
In practice the isp is limited at around 120MPix/s, which is where the 15fps max at 8MPix comes from.
I did my measurements on a static lighted scene, perhaps that is the reason I was able to see 25fps without frameskips.
⇨https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/github_repo_i420toh264
https://github.com/Hermann-SW/fork-raspiraw
https://twitter.com/HermannSW

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7560
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Maximum capture speed

Fri Oct 11, 2019 9:43 am

HermannSW wrote:
Fri Oct 11, 2019 9:25 am
6by9 wrote:
Fri Oct 11, 2019 5:46 am
Csi2 supports up to 1Gbit/s per lane, and the Pi exposes two lanes. The cameras generally produce bayer data at 10bits per pixel. I make that 200MPix/s, ...
It is 231.22Mbits per frame:

Code: Select all

$ echo "scale=2; 3280*2464*3*10/(1024^2)" | bc -ql
231.22
$ 
"3280*2464*3*10" ? Why are you doing 30bits per pixel? Bayer images are not fully sampled RGB.
2x10^9 / (3280 * 2464 * 10) = 24.7fps.

And I see that people are messing with Mbytes/s vs Mbits/s in quoting "100MBps per lane".
Whilst there are overheads on CSI2, it is at the line level not at the byte level, so it does send 8bits per byte. Each lane can carry not far off 1000/8 = 125Mbyte/s.

I don't recall what link frequency the IMX219 is actually set up to run at - someone could reverse engineer the PLL settings from the registers if they could really be bothered.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
HermannSW
Posts: 1657
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Maximum capture speed

Fri Oct 11, 2019 10:20 am

Thanks for uncovering my factor 3 error.
Now all makes sense and explains why 25fps are possible including CSI2 overhead:

Code: Select all

$ echo "scale=2; 2*(1024^3)/(3280*2464*10)" | bc -ql
26.57
$
⇨https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/github_repo_i420toh264
https://github.com/Hermann-SW/fork-raspiraw
https://twitter.com/HermannSW

Return to “Camera board”