User avatar
AverageJim
Posts: 17
Joined: Sun Jan 05, 2014 2:07 pm
Location: Atlanta

Raspistill takes 6 seconds to run.

Sun Jan 05, 2014 2:22 pm

I've tried a number of options, such as reducing the size of the image -w 1024 -h 768, using roi -roi .2,.2,.2,.2, writing to a BMP format, -e bmp -o image.bmp and all of the above and it takes 6+ seconds to generate an image. I'm ssh'ing into the RPi if that makes a difference. I even wrote the file to shm just in case the SD card was acting slow. This is from the Raspberry Pi camera.

Anything to try? Running Raspbian GNU/Linux 7.

Also I tried the nc.traditional -l -p 5001 | mplayer -fps 31 -cache 1024 -
And got:
MPlayer svn r34540 (Debian), built with gcc-4.6 (C) 2000-2012 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing -.
Reading from stdin...
Cache fill: 0.00% (0 bytes)

And it just hangs there.

I am generating images from raspistill, just slowly.

Any ideas?


Thanks,
Jim.

I just ran it with -V and the longest delay comes between the
Connecting camera stills port to encoder input port
and the
Opening output file /run/shm/image.bmp
steps.

Best I can tell is that step accounts for 5 of the six seconds. I run it as root and get the same results. raspistill Camera App v1.3.5

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

Re: Raspistill takes 6 seconds to run.

Sun Jan 05, 2014 4:00 pm

How long does

raspistill -t 1500 -o test.jpg

take?

By default, raspistill takes a picture after running for 5 seconds. The -t option reduces this time, but you cannot really go below 1000ms without exposure problems. But try various numbers and see what works for you.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

User avatar
AverageJim
Posts: 17
Joined: Sun Jan 05, 2014 2:07 pm
Location: Atlanta

Re: Raspistill takes 6 seconds to run.

Sun Jan 05, 2014 6:39 pm

Interesting. I took it down to -t 100 to see what happens. I can't see any difference between that image and the 6 second one. It took 1.2 seconds. Isn't there a way I can get an image faster than that? Since the camera is capable of multi frames per minute there something I don't understand.

Anyway even at 1.2 seconds, I'm concerned I'm not going to be able to do what I need to do. I have a 5 second window to examine an image and compare it to a previously stored image. I'm just a little concerned I'm not going to be able to do it. Suggestions? Can I perhaps grab frames from raspivid?

Thanks,
Jim.

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

Re: Raspistill takes 6 seconds to run.

Sun Jan 05, 2014 7:15 pm

The process of running raspivid is..

run
Test if connected to camera
If connected start up camera in preview mode
run until -t limit hit
change camera mode to stills capture
take picture
go back to preview mode
shut down

Which can take a while. Imagine your phone camera - when you first turn it on it takes while before its ready to take its first shot.

If you want quick response, run raspistill in the background in signal mode, so that when you send the background process a signal it takes the picture. Its already running with the correct exposure so will take the image more quickly.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

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

Re: Raspistill takes 6 seconds to run.

Sun Jan 05, 2014 7:35 pm

AverageJim wrote:Interesting. I took it down to -t 100 to see what happens. I can't see any difference between that image and the 6 second one. It took 1.2 seconds. Isn't there a way I can get an image faster than that? Since the camera is capable of multi frames per minute there something I don't understand.

Anyway even at 1.2 seconds, I'm concerned I'm not going to be able to do what I need to do. I have a 5 second window to examine an image and compare it to a previously stored image. I'm just a little concerned I'm not going to be able to do it. Suggestions? Can I perhaps grab frames from raspivid?

Thanks,
Jim.
What size images do you need ? the smaller the better.

I run raspistill as a subprocess using -t 0 and -tl 0 and take up to a 640x480 section of it and can achieve an image every apporx 750mS using -ex auto, and 800 to 900mS using ex off and -ss 150000

User avatar
AverageJim
Posts: 17
Joined: Sun Jan 05, 2014 2:07 pm
Location: Atlanta

Re: Raspistill takes 6 seconds to run.

Mon Jan 06, 2014 12:09 am

gordon77 wrote:
What size images do you need ? the smaller the better.

I run raspistill as a subprocess using -t 0 and -tl 0 and take up to a 640x480 section of it and can achieve an image every apporx 750mS using -ex auto, and 800 to 900mS using ex off and -ss 150000
How are you capturing the images? Do you use the -roi parameter to do the sectioning? Are you writing to stdout and reading it into a program?

I found that this works as expected:

time raspistill -roi .4,.2,.2,.2 -t 500 -w 900 -h 600 -o test.jpg

But his does not. It hangs forever.
time raspistill -roi .4,.2,.2,.2 -t 0 -w 900 -h 600 -o test.jpg

And this crops the picture somewhat, but not to what the -roi says.
time raspistill -roi .4,.2,.2,.2 -t 100 -w 900 -h 600 -o test.jpg

Thanks,
Jim.

User avatar
AverageJim
Posts: 17
Joined: Sun Jan 05, 2014 2:07 pm
Location: Atlanta

Re: Raspistill takes 6 seconds to run.

Mon Jan 06, 2014 12:23 am

jamesh wrote:The process of running raspivid is..

run
Test if connected to camera
If connected start up camera in preview mode
run until -t limit hit
change camera mode to stills capture
take picture
go back to preview mode
shut down

Which can take a while. Imagine your phone camera - when you first turn it on it takes while before its ready to take its first shot.

If you want quick response, run raspistill in the background in signal mode, so that when you send the background process a signal it takes the picture. Its already running with the correct exposure so will take the image more quickly.
That sounds like the way to go. Thanks, I'll play with that.

Jim.

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

Re: Raspistill takes 6 seconds to run.

Mon Jan 06, 2014 3:00 am

Try searching for raspimjpeg on here

Gordon77

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

Re: Raspistill takes 6 seconds to run.

Mon Jan 06, 2014 8:51 am

gordon77 wrote:Try searching for raspimjpeg on here

Gordon77
Why? Does that help with the OP's problem?
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

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

Re: Raspistill takes 6 seconds to run.

Mon Jan 06, 2014 8:52 am

AverageJim wrote:
gordon77 wrote:
What size images do you need ? the smaller the better.

I run raspistill as a subprocess using -t 0 and -tl 0 and take up to a 640x480 section of it and can achieve an image every apporx 750mS using -ex auto, and 800 to 900mS using ex off and -ss 150000
How are you capturing the images? Do you use the -roi parameter to do the sectioning? Are you writing to stdout and reading it into a program?

I found that this works as expected:

time raspistill -roi .4,.2,.2,.2 -t 500 -w 900 -h 600 -o test.jpg

But his does not. It hangs forever.
time raspistill -roi .4,.2,.2,.2 -t 0 -w 900 -h 600 -o test.jpg

And this crops the picture somewhat, but not to what the -roi says.
time raspistill -roi .4,.2,.2,.2 -t 100 -w 900 -h 600 -o test.jpg

Thanks,
Jim.
-t 0 is the options to 'run forever' so not really a hang! So it's working exactly as expected.

If roi doesn't appear to be correct, do an sudo rpi-update, there was a fix for roi not being correct in all cases last week. If that doesn't fix the problem, can you describe exactly what the problem is.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

User avatar
AverageJim
Posts: 17
Joined: Sun Jan 05, 2014 2:07 pm
Location: Atlanta

Re: Raspistill takes 6 seconds to run.

Mon Jan 06, 2014 11:57 am

jamesh wrote:
-t 0 is the options to 'run forever' so not really a hang! So it's working exactly as expected.

If roi doesn't appear to be correct, do an sudo rpi-update, there was a fix for roi not being correct in all cases last week. If that doesn't fix the problem, can you describe exactly what the problem is.
I did the pi-update before I started this exercise, yesterday.

They say a picture is worth a thousand words. http://fdcga.com/sample/sample.html is the results of three raspistill outputs of the same shot of my messy office and unfinished ceiling.

Thanks,
Jim.

Jim.

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

Re: Raspistill takes 6 seconds to run.

Mon Jan 06, 2014 12:10 pm

Ah, OK. What's happening is that the zoom in to the requested roi is not finishing before the picture is taken. Your -t values are pretty short.

I'm wondering whether to disable the visible zoom in so it jumps straight to position.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

mikerr
Posts: 2774
Joined: Thu Jan 12, 2012 12:46 pm
Location: UK
Contact: Website

Re: Raspistill takes 6 seconds to run.

Mon Jan 06, 2014 12:14 pm

Any particular reason you're using bmp format ?

jpg is accelerated on the pi GPU, bmp isn't.

User avatar
AverageJim
Posts: 17
Joined: Sun Jan 05, 2014 2:07 pm
Location: Atlanta

Re: Raspistill takes 6 seconds to run.

Mon Jan 06, 2014 1:13 pm

mikerr wrote:Any particular reason you're using bmp format ?

jpg is accelerated on the pi GPU, bmp isn't.
No good reason, while browsing, I thought I saw something that said bmp was faster since there wasn't any compression going on, but that didn't turn out to be true. You'll see in my later examples I'm using jpg or png.

User avatar
AverageJim
Posts: 17
Joined: Sun Jan 05, 2014 2:07 pm
Location: Atlanta

Re: Raspistill takes 6 seconds to run.

Mon Jan 06, 2014 1:19 pm

jamesh wrote:Ah, OK. What's happening is that the zoom in to the requested roi is not finishing before the picture is taken. Your -t values are pretty short.

I'm wondering whether to disable the visible zoom in so it jumps straight to position.
OK that makes sense. So my plans are to fire off a exec call (in C) to run raspistill ... -s, capture the process ID and send kills to that ID, looking for a new file being generated via the inotify(7) function.

Just for explanation, I'll be comparing the most recent two images (a portion of them) for changes. If the changes are significant enough I'll then do a bit more processing to make sure the change is what I'm wanting to sense.

Thanks for all the help. The camera is a real jewel, but this software is what makes it usable.

Kudos

Jim.

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

Re: Raspistill takes 6 seconds to run.

Mon Jan 06, 2014 1:34 pm

Use SIGUSR1 rather than SIGKILL, but otherwise that should do the job. Remember to out a %d (or %03d or similar) in your filename somewhere to get multiple files produced.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

User avatar
AverageJim
Posts: 17
Joined: Sun Jan 05, 2014 2:07 pm
Location: Atlanta

Re: Raspistill takes 6 seconds to run.

Mon Jan 06, 2014 1:56 pm

jamesh wrote:Use SIGUSR1 rather than SIGKILL, but otherwise that should do the job. Remember to out a %d (or %03d or similar) in your filename somewhere to get multiple files produced.
I was sort of using kill generically since kill(2) kill - send signal to a process. Nice to know about the format of the filename including parsing %d. I missed that in my reading.

Thanks,
Jim.

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

Re: Raspistill takes 6 seconds to run.

Mon Jan 06, 2014 2:55 pm

AverageJim wrote:
jamesh wrote:Use SIGUSR1 rather than SIGKILL, but otherwise that should do the job. Remember to out a %d (or %03d or similar) in your filename somewhere to get multiple files produced.
I was sort of using kill generically since kill(2) kill - send signal to a process. Nice to know about the format of the filename including parsing %d. I missed that in my reading.

Thanks,
Jim.
It's basically the same formatting as printf, obviously limited by the single parameter (which is the frame number).

Its always annoyed me that the kill command isn't actually a kill command, but a send signal to process and if no parameter is specified send kill command.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

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

Re: Raspistill takes 6 seconds to run.

Mon Jan 06, 2014 7:47 pm

jamesh wrote:
gordon77 wrote:Try searching for raspimjpeg on here

Gordon77
Why? Does that help with the OP's problem?
Yes l thought he wanted to capture pics quick which it can do

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

Re: Raspistill takes 6 seconds to run.

Mon Jan 06, 2014 8:14 pm

gordon77 wrote:
jamesh wrote:
gordon77 wrote:Try searching for raspimjpeg on here

Gordon77
Why? Does that help with the OP's problem?
Yes l thought he wanted to capture pics quick which it can do
I would expect that to be slower, or at least no faster for full resolution captures - after all the camera and driving software is the same.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

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

Re: Raspistill takes 6 seconds to run.

Mon Jan 06, 2014 8:19 pm

jamesh wrote:
gordon77 wrote:
jamesh wrote:
Why? Does that help with the OP's problem?
Yes l thought he wanted to capture pics quick which it can do
I would expect that to be slower, or at least no faster for full resolution captures - after all the camera and driving software is the same.
I 'd seen quotes of 67ms . I found it gave around 500ms in my setup compared to around 600ms, both using auto ex

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

Re: Raspistill takes 6 seconds to run.

Tue Jan 07, 2014 9:32 am

Not sure that's actually possible with full frame images - it would be faster with video sized images. Also not entirely sure what is being measured.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

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

Re: Raspistill takes 6 seconds to run.

Thu Jan 09, 2014 10:38 pm

jamesh wrote:Not sure that's actually possible with full frame images - it would be faster with video sized images. Also not entirely sure what is being measured.
I've been playing around with the resizer stuff for the latest version of picamera, and it's sort of possible... Here's a quick snippet from release 1.0 (which should be out at the weekend - plug plug) which captures full-frame images (2592x1944) via the video port, scales them down to 1024x768 (that's the "sort of" bit - they're full frame, but not full size), encodes them as JPEG, and spits them out to the disk as fast as it can:

Code: Select all

import time
import picamera

frames = 30

with picamera.PiCamera() as camera:
    camera.resolution = (2592, 1944)
    start = time.time()
    camera.capture_sequence([
        'image%02d.jpg' % i
        for i in range(frames)
        ], resize=(1024, 768), use_video_port=True)
    finish = time.time()
print('Captured %d frames at %.2ffps' % (
    frames,
    frames / (finish - start)))
On my Pi, I get about 10fps out of this. It's also worth noting that the first four or five frames get progressively brighter as the camera adjusts its exposure (I deliberately didn't include the usual upfront delay allowing the camera time to adjust).

I'm guessing for the OP's purposes of comparing different frames that actually JPEG encoding isn't all that useful and what you'd really like is, say, a matrix of the pixel's values? If that's the case, you might want to check out the raw capture recipes for picamera too.


Dave (plugging his picamera library yet again...)

User avatar
AverageJim
Posts: 17
Joined: Sun Jan 05, 2014 2:07 pm
Location: Atlanta

Re: Raspistill takes 6 seconds to run.

Fri Jan 10, 2014 12:13 am

waveform80 wrote: I'm guessing for the OP's purposes of comparing different frames that actually JPEG encoding isn't all that useful and what you'd really like is, say, a matrix of the pixel's values? If that's the case, you might want to check out the raw capture recipes for picamera too.


Dave (plugging his picamera library yet again...)
You are right, yuv format probably is a better one to do what I'm trying to do, for a couple of reasons however I'm fairly certain I can get what I want from jpg. Thanks for the idea, if run into trouble using RGB and jpg I'll investigate yuv. I have a bit of at time crunch and can't really take the time to learn about yuv to the degree I'd need to complete this project.

Thanks,
Jim.

User avatar
AverageJim
Posts: 17
Joined: Sun Jan 05, 2014 2:07 pm
Location: Atlanta

Re: Raspistill takes 6 seconds to run.

Fri Jan 10, 2014 12:15 am

Another thing. I don't do Python. I take exception to the author's attitude towards curly braces so I refuse to use it. :)

Return to “Camera board”