Andre_Leonardo
Posts: 59
Joined: Wed Nov 12, 2014 1:47 am

Image capturing duration

Sun Mar 15, 2015 6:46 am

It normally takes around 6s to capture an image and give output is there a way to reduce this time. And is there a difference in efficiency when using os library and picamera library

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

Re: Image capturing duration

Sun Mar 15, 2015 8:40 am

Using raspistill you can get an image every 0.5 sec or less, l would have thought picamera could be similar.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24133
Joined: Sat Jul 30, 2011 7:41 pm

Re: Image capturing duration

Sun Mar 15, 2015 9:45 am

You are using the default settings for Raspistil, which is to run the preview for 5 seconds, then take the picture.

Use the -t parameter to set a smaller value. (smallest is about 500ms)
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

Andre_Leonardo
Posts: 59
Joined: Wed Nov 12, 2014 1:47 am

Re: Image capturing duration

Sun Mar 15, 2015 12:02 pm

Thanx :)

User avatar
waveform80
Posts: 308
Joined: Mon Sep 23, 2013 1:28 pm
Location: Manchester, UK

Re: Image capturing duration

Thu Mar 19, 2015 12:47 pm

Yup, there's very little difference in performance between shelling out for raspistill and using picamera if all you're concerned about is capturing an image. With the former you've got a nice fast C program, but you've got the overhead of spawning a new process. With the latter you've got a slow python library but none of the process overhead (and in both cases, all the real work is getting done by the GPU anyway because both rely on the MMAL library under the hood).

There're a few options that picamera will give you for speeding things up that aren't possible without modifying raspistill (e.g. capturing images from the video port instead) but there's precious little difference otherwise.

Dave.

jolouis
Posts: 15
Joined: Wed Sep 10, 2014 8:50 pm

Re: Image capturing duration

Fri Mar 20, 2015 8:42 pm

Yup, there's very little difference in performance between shelling out for raspistill and using picamera if all you're concerned about is capturing an image. With the former you've got a nice fast C program, but you've got the overhead of spawning a new process.
Just to add to Dave's comment if you're being really paranoid the fastest option I've found is to launch raspistill with the -t 0 -s options. This causes it to load up and wait for a Signal in order to trigger the capture. What that means is you can incur the "initialization/load" time at any point (typically early on when you're doing something like starting up your program, script, etc), and then when you want the actual capture all you have to do is fire off a SIGUSR1. The theory is that sending a signal to the already initialized and ready to go Raspistill requires less time/overhead than launching it from scratch.

In reality I'm sure it doesn't make a huge time difference, but out of principle when you want every clock cycle to count it's my preferred approach. YMMV.

User avatar
waveform80
Posts: 308
Joined: Mon Sep 23, 2013 1:28 pm
Location: Manchester, UK

Re: Image capturing duration

Fri Mar 20, 2015 9:02 pm

jolouis wrote:
Yup, there's very little difference in performance between shelling out for raspistill and using picamera if all you're concerned about is capturing an image. With the former you've got a nice fast C program, but you've got the overhead of spawning a new process.
Just to add to Dave's comment if you're being really paranoid the fastest option I've found is to launch raspistill with the -t 0 -s options. This causes it to load up and wait for a Signal in order to trigger the capture. What that means is you can incur the "initialization/load" time at any point (typically early on when you're doing something like starting up your program, script, etc), and then when you want the actual capture all you have to do is fire off a SIGUSR1. The theory is that sending a signal to the already initialized and ready to go Raspistill requires less time/overhead than launching it from scratch.

In reality I'm sure it doesn't make a huge time difference, but out of principle when you want every clock cycle to count it's my preferred approach. YMMV.
Actually camera init is a fairly lengthy process - a good few hundred ms or so even in C, so "pre-paying" init time is a good idea if you want as little time as possible between trigger and capture. The major disadvantage to this is that the camera eats another 250mA of power, but that's probably only a concern for people running on batteries.

Incidentally, in picamera the construction of the PiCamera() object initializes the camera so the equivalent is simply:

Code: Select all

with picamera.PiCamera() as camera:
    # camera is now initialized
    # wait for some trigger...
    camera.capture('foo.jpg')
(actually that's not *entirely* equivalent in that capture still creates an encoder behind the scenes but it's close - to get absolutely the same as raspistill would involve waiting on a generator with capture_sequence)


Dave.

Return to “Camera board”