awwshuckyducky
Posts: 3
Joined: Thu Mar 01, 2018 9:28 pm

Low framerate with raspistill

Thu Mar 01, 2018 10:26 pm

I'm a pi noob, but am using a raspberry pi 3 for a research project. We are trying to use raspistill to capture timelapse images from within a python script that we run at start-up. When we call raspistill (even directly from the command line), we struggle to achieve even 1.5 frames per second before it starts skipping frames. We'd like to get at least 1fps for our application. I'm using the following command:

Code: Select all

raspistill -n -r -awb off -awbg 1,1 -ss 4000 -ISO 100 -t 60000 -tl 1000 -o "image-%04d.jpg"
From looking at other posts, it seems like we should be able to capture with 1fps with no problem. Any advice as to how I can improve performance of our system to get that frame rate up?

I used NOOBs to set up raspbian on the sd card. I've used top to see if there were other programs taking up considerable resources (since our script should really be the only thing running) and didn't see anything substantial.

I've also tried using nice to set a very low priority for raspistill, but that didn't seem to help much.

Any assistance would be greatly appreciated!

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

Re: Low framerate with raspistill

Fri Mar 02, 2018 8:39 am

How big are your images? How fast is your storage?
Requesting raw bayer data will require around 13MB for each frame. You SD card could have problem saving 13MB/s. Do you really need the raw bayer data?
You can try a faster storage(usb hdd), removing the raw data or using the "-bm" switch. To check storage speed you could try to save the images as a test to /run/shm folder, which will store the images in RAM. You will only be able to store 10 to 15 frames there but if you don't skip frames there your storage is to slow.

awwshuckyducky
Posts: 3
Joined: Thu Mar 01, 2018 9:28 pm

Re: Low framerate with raspistill

Thu Mar 08, 2018 7:58 am

ethanol100 wrote:
Fri Mar 02, 2018 8:39 am
How big are your images? How fast is your storage?
Requesting raw bayer data will require around 13MB for each frame. You SD card could have problem saving 13MB/s. Do you really need the raw bayer data?
You can try a faster storage(usb hdd), removing the raw data or using the "-bm" switch. To check storage speed you could try to save the images as a test to /run/shm folder, which will store the images in RAM. You will only be able to store 10 to 15 frames there but if you don't skip frames there your storage is to slow.
Sorry for the delay!

We do need the raw data for our project, and the images with the raw data are about 14 MB and we're using a Sandisk Ultra 32GB micro sd. It claims a minimum 10MB/s write speed, but I've read reviews stating that some cards will get up to 40MB/s while others only claim around 20, though it seems like these results would depend on the types of benchmarks being used.

I tried writing the images to the /run/shm folder, and got no skipped frames. So, it seems as if the issue is the disk storage speed. Do you think a possible solution would be to write the files to memory using tempfs and then have a shell script to move those files to disk as the timelapse is taking place? I read here:
https://www.howtoforge.com/storing-file ... with-tmpfs that I can make a partition in RAM and assign it a size, but I'd be limited by the amount of RAM on the pi. We'll end up having around 1GB worth of image files for each timelapse.

I wasn't able to find documentation on the "-bm" switch. What does that do?

Thanks for all your help!

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

Re: Low framerate with raspistill

Thu Mar 08, 2018 8:05 pm

You can try to reduce the size of the actual jpeg if you are only using the raw images. You can set the quality to a very low value(-q 1), reduce the output size (-w 32 -h 24) and disable the thumbnail(-th none). This will reduce the size to around 10MB.

Writing to SD is not very fast for the pi. I would suggest a usb storage like an external disk or fast usb stick.

Usually the camera is switching between "preview" and "still capture" mode, each time it needs to take a picture. Burst mode ("-bm") forces the camera to stay in the still capture mode. During switching you will need one additional frame to get a good one, and this can save some time. The auto exposure mode will not work in this mode and the settings are used for all taken images. The first duration between first and second frame will have a longer duration, but all following images should be quicker. But this should not be important for your use case.

gordon77
Posts: 3209
Joined: Sun Aug 05, 2012 3:12 pm

Re: Low framerate with raspistill

Thu Mar 08, 2018 8:46 pm

Try -t 0 -tl 0, this should save some time.

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

Re: Low framerate with raspistill

Fri Mar 09, 2018 12:55 am

awwshuckyducky wrote:
Thu Mar 08, 2018 7:58 am
We do need the raw data for our project, and the images with the raw data are about 14 MB and we're using a Sandisk Ultra 32GB micro sd. It claims a minimum 10MB/s write speed,
...
Do you think a possible solution would be to write the files to memory using tempfs and then have a shell script to move those files to disk as the timelapse is taking place?
No. One image takes 14MB, so 74 will take more than 1GB, and that is all your main memory.

The frame skips you only see when storing on SD card indicate that your effective write speed is below 14MB/s, and therefore the method you asked for will slowly fill up all memory, and then start producing frame skips. No system can work with input data rate bigger than output data rate for long.

P.S:
I use /dev/shm as storage for raspiraw as well, but contrary to your target (big frames, low framerate) I am interested in the opposite, small frames (eg. 640x128_s) at very high framerate (665fps). SIze of /dev/shm allows for up to 16s or recording.
--> Raspberry camera / gstreamer / raspivid / raspiraw (bookmark list):
https://stamm-wilbrandt.de/en/Raspberry_camera.html

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

awwshuckyducky
Posts: 3
Joined: Thu Mar 01, 2018 9:28 pm

Re: Low framerate with raspistill

Wed Mar 14, 2018 1:35 am

Thanks everyone for their input. I tried writing to my own USB drive and it was a little bit better, but still not quite the performance we desired. Now, by writing to fast USB drive, with decreased quality jpgs, burst mode, and no thumbnail, we are able to achieve even better than 1fps.

FEELS GOOD

Return to “Camera board”

Who is online

Users browsing this forum: rotation and 14 guests