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

Long exposures

Thu Nov 21, 2013 5:38 pm

Good news. I have a chance to look at this, and have fixed the lockup when you have over a certain time (it's now going to die at 30s - caused by a timeout in the GPU), but can now get almost 2s of exposure, no further. This is the max possible just by using the exposure registers in the sensor. However, according to Omnivision I should be able to increase the exposure further by increasing the frame length. So once I get confirmation I'll take a look at that.

I'll hopefully be able to checkin the code tomorrow (even if just the lockup fix and extend to 2s), but as it's GPU side changes, not sure how low that will take to get to rpi-update.
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: 23385
Joined: Sat Jul 30, 2011 7:41 pm

Re: Long exposures

Thu Nov 21, 2013 5:43 pm

Although I have noticed that the EXIF data is wrong so will need to fix that as well - the calculation doesn't work above 1000000us!
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."

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: Long exposures

Thu Nov 21, 2013 6:25 pm

Sounds good...

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

Re: Long exposures

Thu Nov 21, 2013 8:01 pm

Yes, sounds good news :D

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

Re: Long exposures

Fri Nov 22, 2013 9:32 pm

Spent all day trying to get long exposures. Not yet working, not sure why. Will have another go Monday. If still no luck I will release the lockup fix as it stands which will get about 2 second and get rid of the lockup for night mode.
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: 23385
Joined: Sat Jul 30, 2011 7:41 pm

Re: Long exposures

Sat Nov 23, 2013 10:01 am

For those interested, the 3 registers for exposure time only go up to a certain value - measure in 16ths of a line. And about 2s is the maximum exposure you can get from those registers. However, you can increase the linelength which means each line takes longer to read from the sensor (you only use the required pixels from the line), and this compounds up to make the exposure longer. But we don't normally change line length since we've never need to go above a second exposure. So I modified the camera driver to allow the changing of the HTS as required. But it locks up. I have a horrible feeling that because the numbers being used are so large (things are measure in nanoseconds, so a long exposure is a LOT of nanoseconds) that we may be exceeding the size of a 32 bit int somewhere in the system (not the driver, I already take care of things there) and something is overflowing and going pear shaped. If I can find where, then I can hopefully change stuff to 64 bit values. It's finding the problem that will be difficult.
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."

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: Long exposures

Sat Nov 23, 2013 10:43 am

How is the noise @ 2 sec? If it's already 'pretty bad' you might be wasting time going longer. That said, if the image quality is usable it would be fantastic to have real long exposures.

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

Re: Long exposures

Sat Nov 23, 2013 11:06 am

poing wrote:How is the noise @ 2 sec? If it's already 'pretty bad' you might be wasting time going longer. That said, if the image quality is usable it would be fantastic to have real long exposures.
It actually looked pretty good although I only took a picture under the desk handheld.
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: 23385
Joined: Sat Jul 30, 2011 7:41 pm

Re: Long exposures

Mon Nov 25, 2013 3:19 pm

I'm going to have to stop looking at exposure longer than the 2s or so I get now. It looks like the investigation and changes to the underlying code will take longer than I have (which, as of now, is almost nothing). I've pushed the change to the GPU firmware to stop the lockup and get times up to I think about 2s from the current 0.35s so its a good improvement. Not sure how long that will take to be released - I'll ask Dom what his schedule is.

Soz.
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: 4117
Joined: Sun Aug 05, 2012 3:12 pm

Re: Long exposures

Mon Nov 25, 2013 5:41 pm

Thanks James, any advances appreciated :D

Gordon77

mark79
Posts: 10
Joined: Thu May 23, 2013 3:50 pm

Re: Long exposures

Thu Dec 05, 2013 1:08 am

In the post titled "exposure" it sounds like the above update for long exposures is now available. In what mode(s) are the long exposures available? I just updated earlier today and the longest exposure I'm getting in the night mode is still 1/4 second at ISO 800. I'm not passing an ISO setting and the camera is outdoors at night with almost no light outside.

I've tested various parameters and can manually set the shutter speed to a longer setting where the EXIF data reads 1 second, though I can't use a manual setting in my application. I need the camera to be able to automatically expose as long as possible when its dark, as well as automatically expose properly in daylight (as I'm using the same command regardless of time of day). What is the best setting for this?

If the night setting doesn't currently allow for this broad of a range, can raspistill be modified to allow for up to 1 second exposure at ISO 800 with the night (or verylong) exposure mode? If it could be modified to auto expose up to ISO 1250 or 1600 at 1 second, that'd be even better. I'd rather have a grainy image than a mostly (or completely) black one.

Thanks James for all your work on the pi camera module!

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

Re: Long exposures

Thu Dec 05, 2013 3:59 am

Try -ex off and set -ss to the exposure time. You can also set -ISO.

Gordon77

maui
Posts: 25
Joined: Sun Jul 08, 2012 10:10 am

Re: Long exposures

Thu Dec 05, 2013 5:02 am

good morning James,

thank you for looking at the locking up problem. The 2 second exposure works great already.
sudo raspistill -ex verylong -o verylong.jpg
Image Image

I made some pictures yesterday and the -ex night turned out as dark as the normal. and now without -iso 800 it turns out brighter.
So for dark images don't use the ISO settings, and everythink will be alright ;)

James don't give up

User avatar
jbeale
Posts: 3476
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Long exposures

Thu Dec 05, 2013 5:55 am

Just FWIW: Your "normal.jpg" EXIF data says 1/8 sec at ISO 500, and your "verylong.jpg" says 1 sec at ISO 200. So the latter image is 3 stops brighter in shutter speed and 1.5 stops darker in ISO, giving you only a net 1.5 stop gain.

I tried a night view with raspistill -ex night -o normal.jpg which gave me 0.25 second shutter at ISO 800.
Then I did: raspistill -ex sports -ss 1000000 -o long.jpg and I got 0.972724 seconds at ISO 1000. I think the 'sports' mode allows up to ISO 1250 (?) even though direct-setting ISO is limited to 800 for some reason. That is more than 2 stops improvement and you can see the difference between these two exposure settings pretty clearly:
Image
Image
For what it's worth, this particular camera is using an aftermarket 6mm f/1.8 M12 lens that I hacked onto it, instead of the stock 3.6mm f/2.9 lens, but the comparison between the two images is still valid. I also played with an 8mm f/1.4 M12 lens, and the nighttime images were brighter but had very soft focus to say the least.

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: Long exposures

Thu Dec 05, 2013 7:23 am

Just tried and the highest ISO I was able to get was

Code: Select all

raspistill -ss 500000 -ex sports -ev 25 -o long.jpg
which gives 1/2 sec @ ISO 1600. If you extend the shutter speed beyond that the ISO starts to fall again.

Sadly for the OP if you do not set the -ss option -ex sports will not go longer than 1/60.

Longest exposure seems to be

Code: Select all

raspistill -ss 800000 -ex sports -ev 25 -o long.jpg
which gives 0.8 sec @ ISO 1250.

mark79
Posts: 10
Joined: Thu May 23, 2013 3:50 pm

Re: Long exposures

Fri Dec 06, 2013 5:27 am

Is it possible to modify raspistill so that either the night or verylong exposure mode can automatically expose up to the maximum exposure that's currently available via manually setting the shutter speed in the sports mode?

By setting the timeout parameter to 10 seconds, I was able to get a 1 second exposure at ISO 1600 (with the EXIF data indicating a Light Value of -0.9 and Brightness Value of 0.03 or 0.04):

Code: Select all

raspistill -ss 1000000 -ex sports -o test.jpg -t 10000
If one of the exposure modes could be modified to automatically expose up to 1 second at ISO 1600 that'd be a huge help for time-lapses and other scripts that use the same command regardless of time of day.

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: Long exposures

Fri Dec 06, 2013 7:30 am

Why not write a python program like so: http://www.raspberrypi.org/phpBB3/viewt ... 50#p460989 and choose exposure mode based on the exif?

Niall101
Posts: 16
Joined: Fri May 10, 2013 2:24 pm
Location: Clinterty Observatories, Aberdeen

Re: Long exposures

Fri Dec 06, 2013 9:33 am

Good news James, and thanks for all your efforts in trying to solve these issues - for those of us, probably in the minority, who would love to be able to get longer exposures out of the PiCam.

I still have not really had enough time to 'play' with my setup, but have been trying to at least keep up with the developments that you have been working on.

Do you think that there will ever be a possibility of creating an interface that more closely resembles that of a standard (D)SLR camera, i.e.:

AUTO mode (where some form of 'pre-exposure' determines how best to capture the next image)

APERTURE PRIORITY mode (not really an option for us to worry about, as our lens would be 'fixed' - unless we get clever with the GPIO !!)

SHUTTER PRIORITY mode (where we specify an absolute exposure time - the mode that I am most interested in, although it may actually be 'MANUAL' mode, because I would want all images captured at the same ISO, or 'electronic gain' settings)

MANUAL mode (where the likes of <raspistill> allows us to set every parameter - providing obvious conflicts are avoided)

After all, even the 'graininess' that is prevalent in higher ISO exposures (where the camera 'gain' has had to be increased) is relatively easy to deal with in post-processing packages like the incredible PixInsight software.

What I really want to find time to try now, is to take sequential 2-second exposures (of the overhead sky, through a very wide-angle lens) and to then statistically average rolling sub-sets of these images to artificially extend the apparent exposure time (either using simple arithmetic summing of, say, five images at a time, or by some form of rolling Kalman-filter - perhaps even a combination of both processes). However, whichever statistical process works best - it will work better with a simple 'longer exposure' to begin with (restricted only by star-trails as the earth rotates underbeath the fixed vista overhead).

I already do this with a dedicated asronomical imager, using 10-second exposures, and the results are actually very nice indeed. But that imager is only 640x480 resolution. I would love to see the same effect from a 5MP imager like the PiCam.

Keep up the good work.

Cheers,
Niall
Scatch-built BBC B in 82: blank PCB+scavenged plastics& PSU. Sinclair Calc & ZX81 kits in 74&82. PONG (AY-3-8500) in 77. 1st PC in 89: 386/25+387&10MbHDD. Have previewed pictures with my PiCam. I'll maybe save one next week (new to Linux)!

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

Re: Long exposures

Fri Dec 06, 2013 9:39 am

Niall101 wrote:Good news James, and thanks for all your efforts in trying to solve these issues - for those of us, probably in the minority, who would love to be able to get longer exposures out of the PiCam.

I still have not really had enough time to 'play' with my setup, but have been trying to at least keep up with the developments that you have been working on.

Do you think that there will ever be a possibility of creating an interface that more closely resembles that of a standard (D)SLR camera, i.e.:

AUTO mode (where some form of 'pre-exposure' determines how best to capture the next image)

APERTURE PRIORITY mode (not really an option for us to worry about, as our lens would be 'fixed' - unless we get clever with the GPIO !!)

SHUTTER PRIORITY mode (where we specify an absolute exposure time - the mode that I am most interested in, although it may actually be 'MANUAL' mode, because I would want all images captured at the same ISO, or 'electronic gain' settings)

MANUAL mode (where the likes of <raspistill> allows us to set every parameter - providing obvious conflicts are avoided)

After all, even the 'graininess' that is prevalent in higher ISO exposures (where the camera 'gain' has had to be increased) is relatively easy to deal with in post-processing packages like the incredible PixInsight software.

What I really want to find time to try now, is to take sequential 2-second exposures (of the overhead sky, through a very wide-angle lens) and to then statistically average rolling sub-sets of these images to artificially extend the apparent exposure time (either using simple arithmetic summing of, say, five images at a time, or by some form of rolling Kalman-filter - perhaps even a combination of both processes). However, whichever statistical process works best - it will work better with a simple 'longer exposure' to begin with (restricted only by star-trails as the earth rotates underbeath the fixed vista overhead).

I already do this with a dedicated asronomical imager, using 10-second exposures, and the results are actually very nice indeed. But that imager is only 640x480 resolution. I would love to see the same effect from a 5MP imager like the PiCam.

Keep up the good work.

Cheers,
Niall
I think almost all the possible parameters that can be set are already settable using raspistill/vid already. You can set ISO, shutter time and there is a scene mode option for example, which I think covers most of your points.
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
jbeale
Posts: 3476
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Long exposures

Fri Dec 06, 2013 5:37 pm

Niall101 wrote: What I really want to find time to try now, is to take sequential 2-second exposures (of the overhead sky, through a very wide-angle lens) and to then statistically average rolling sub-sets of these images to artificially extend the apparent exposure time (either using simple arithmetic summing of, say, five images at a time, or by some form of rolling Kalman-filter - perhaps even a combination of both processes). However, whichever statistical process works best - it will work better with a simple 'longer exposure' to begin with (restricted only by star-trails as the earth rotates underbeath the fixed vista overhead).

I already do this with a dedicated asronomical imager, using 10-second exposures, and the results are actually very nice indeed. But that imager is only 640x480 resolution. I would love to see the same effect from a 5MP imager like the PiCam.l
If you want to see 5 MP with long exposures, this is one application where using RAW format is an advantage. As light levels decrease from full sunlight, the R-Pi imaging pipeline uses increasingly aggressive noise reduction and the true resolution drops quite significantly, so any exposure with 1/4 sec. or longer has nothing like 5 MP effectively.

The only way I know of to completely avoid the built-in noise reduction is to extract the RAW data and do your own image adjustments, dark subtraction, frame averaging etc. In most cases it's not practical because it is so slow (the GPU is orders of magnitude faster than the ARMv6 CPU). But astro-imaging is the rare case where it makes sense. See also:
http://bealecorner.org/best/RPi/
https://github.com/illes/raspiraw

sharix
Posts: 200
Joined: Thu Feb 16, 2012 11:29 am
Location: Slovenia

Re: Long exposures

Fri Dec 06, 2013 9:34 pm

@jbeale, I tried with your settings in an almost completely dark room:

Code: Select all

/opt/vc/bin/raspistill -ex sports -ss 1000000 -o test.jpg
The image is very dark, and exif info says ISO 500 and shutter speed value 0.04.
Why doesn't it go up to 1 second shutter speed and ISO 1000?

User avatar
jbeale
Posts: 3476
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Long exposures

Fri Dec 06, 2013 11:19 pm

There is exif:ShutterSpeedValue and exif:ExposureTime which are often very different and I don't know which one is correct. I just tried it in complete darkness, and got the same results as you. But check this out. I cracked open the box so there is a little light inside, and did it again. Then I tried again in nearly full black, but with 10 sec delay.

Code: Select all

$ raspistill -ex sports -ss 1000000 -o dark3.jpg
$ identify -verbose dark3.jpg | grep ISO
    exif:ISOSpeedRatings: 1000
$ raspistill -t 10000 -ex sports -ss 1000000 -o dark5.jpg
$ identify -verbose dark5.jpg | grep ISO
    exif:ISOSpeedRatings: 1600
It looks to me like the autoexposure setting process that cranks up the ISO setting in "-ex sports" moves more slowly in low/no light. Just as mark79 mentioned in a few posts above, you need to allow something like 10 seconds for the -ex sports setting ISO to reach the max value of 1600.

Note: I used identify -verbose to read exif tags but that is slow on large files (because it generates a histogram of all pixels, etc). It is faster to use exiftool:

Code: Select all

$ sudo apt-get install libimage-exiftool-perl

$ raspistill -ex sports -ss 1000000 -o dark8.jpg
$ exiftool dark8.jpg | grep 'Shutter Speed Value\|ISO'
ISO                             : 500
Shutter Speed Value             : 1

$ raspistill -ex sports -ss 1000000 -t 10000 -o dark9.jpg
$ exiftool dark9.jpg | grep 'Shutter Speed Value\|ISO'
ISO                             : 1600
Shutter Speed Value             : 1

mark79
Posts: 10
Joined: Thu May 23, 2013 3:50 pm

Re: Long exposures

Sun Dec 08, 2013 2:00 pm

Before I tried the 10 second timeout, I was noticing the same thing with the sports mode, and an issue with the verylong mode in low light.

I did a few simple tests by turning down the dimmer on my lights at night: when the light level dropped to where raspistill was exposing near 1 second at ISO 200 in the verylong mode, it started giving a shutter speed of 1/6173 second at ISO 200 (the Light Value in the EXIF data read 14.7 and the Brightness Value read 0). If I exposed in night exposure mode, I got 1/4 second at either ISO 640 or ISO 800 with the same light level or slightly dimmer (the Light Value read either 2.1 or 2.4 and the Brightness Value read either 0.04 or 0.07). Without passing an exposure mode parameter, the default mode gave 1/8 second at ISO 500 (with a Light Value of 3.7 and Brightness Value of either 0.02 or 0.04). I'm not passing any additional parameters to raspistill -- my tests were run with these commands:

Code: Select all

raspistill -ex verylong -o verylong.jpg
raspistill -ex night -o night.jpg
raspistill -o default.jpg
I have a couple of time-lapse webcams running on the roof (one is the regular Pi Camera Module and one is the Pi NoIR Camera Module) -- at night, if they're pointed at a very dark location, they give the same results I described above: the verylong exposure mode gives a 1/6173 second exposure at ISO 200 (with a Light Value of 14.7 and Brightness Value of 0), the night exposure mode gives a 1/4 second exposure at ISO 800 (with a Light Value of 2.1 and a Brightness Value of 0.02), and the default exposure mode gives a 1/8 second at ISO 500 (with a Light Value of 3.7 and Brightness Value of 0.02). All the Raspberry Pis were updated/upgraded via apt-get and rpi-update a few days ago -- the Linux version reads: 3.10.21+ #604 PREEMPT Mon Dec 2 20:17:09 GMT 2013 armv6l

When testing the sports mode on these same 3 cameras (and not setting a longer timeout), the maximum exposure I got was 1 second at ISO 500 (with a Light Value of 0.8 and Brightness Value of 0 or 0.01). For this test, I used the same command jbeale used:

Code: Select all

raspistill -ex sports -ss 1000000 -o long.jpg
It seems that the sports exposure mode does need more time to determine the full exposure when the light level is very low, and that the verylong exposure mode wraps around to a very short exposure when it doesn't have enough time to determine a longer exposure. From my tests, the verylong exposure mode doesn't go above ISO 200, and the night exposure mode is limited to 1/4 at ISO 800 (even with setting a timeout of 10 or 20 seconds).

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

Re: Long exposures

Sun Dec 08, 2013 4:20 pm

Remember that in low light, frames are exposure for longer so need more time to get in. This means that if you need a few frames to get the exposure correct, it will take longer to get it right because each frame takes longer.
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."

mark79
Posts: 10
Joined: Thu May 23, 2013 3:50 pm

Re: Long exposures

Sun Dec 08, 2013 5:39 pm

thanks James!

Is there any way to get the night or verylong exposure mode to automatically go up to 1 second at ISO 1600 without passing any shutter speed setting? (provided the timeout is long enough)

If its not currently possible, is this something that could be changed in raspistill or the camera firmware?

Return to “Camera board”