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

Re: Long exposures

Sun Dec 08, 2013 7:02 pm

mark79 wrote: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?
I think that would need a GPU change to the camera tuning (there are different sets of parameters for each of the exposure modes - I think I can force high ISO and long shutters in there, but need to check)
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

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

Re: Long exposures

Wed Dec 11, 2013 8:08 pm

jamesh wrote:
mark79 wrote: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?
I think that would need a GPU change to the camera tuning (there are different sets of parameters for each of the exposure modes - I think I can force high ISO and long shutters in there, but need to check)
If you could check (whenever you have time), I'd greatly appreciate it! If there's a way to set or automatically allow any ISO higher than 1600, that'd be very much welcomed as well!

I have come up with a solution to read the EXIF data and adjust the parameters being passed to raspistill for every shot, though it's not as efficient (nor as simple) as if it were built into the exposure modes. If anyone is interested in this, you'll need to install exiftool and bc:

Code: Select all

apt-get install libimage-exiftool-perl
apt-get install bc
And run a script with a loop similar to this (this has been modified from the actual code I'm using to remove parts unnecessary for this example):

Code: Select all

#!/bin/bash

lightValueTimesTen=150
while [ true ]; do
	if [ "$lightValueTimesTen" -lt 15 ]; then
		timeout=10000
		exposure="sports --shutter 1000000"
	elif [ "$lightValueTimesTen" -lt 25 ]; then
		timeout=5000
		exposure="sports --shutter 800000"
	else
		timeout=5000
		exposure="night"
	fi
	outputfile="pi`date +%s`.jpg"
	raspistill --exposure $exposure --output "$outputfile"  --verbose --timeout $timeout
	lightValue=`exiftool "$outputfile" -LightValue | sed "s/.*: //"`
	lightValueTimesTen=`echo "$lightValue * 10" | bc -l | sed "s/\..*//"`
	sleep 60
done
I do this in two steps to avoid the possibility of underexposure or overexposure in the transition times when the light is changing at dusk or dawn. The settings may not be the most optimal but are pretty close. Essentially, this allows for auto-exposure from minimum to maximum exposure on the Pi Camera Module when creating a time-lapse or running the camera as a live webcam. I only coded this last night after it was dark so won't have actual tests for both dawn and dusk until later this evening. Right now, this is running on one of my live time-lapse cameras, visible at: http://markmarano.com/live-time-lapse-w ... pi-camera/

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

Re: Long exposures

Wed Dec 11, 2013 8:21 pm

I'm not sure a >1600 ISO would be any good. Not sure what the max analogue gain (applied in the sensor) is, although we can add gain digitally in the ISP. The problem would be very very bad noise.
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

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

Re: Long exposures

Fri Dec 13, 2013 1:30 pm

I'm not sure how others feel, but I'd take the grain if it means I'm going to get an exposure. When I leave the cameras running all night in the dark, every little bit of exposure helps. Another stop (if we could set the ISO to 3200) would be a great help in being able to see something in the night exposures (even if its just a little more contrast between the sky and shadows of trees).

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

Re: Long exposures

Fri Dec 13, 2013 2:26 pm

I doubt there will be very much difference between pushing the gain higher in the sensor and taking the ISO 1600 exposure and push it in post.

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

Re: Long exposures

Fri Dec 13, 2013 3:21 pm

The analog gain register, according to the docs, is 9 bits, but is effectively 5p4, so that a max a-gain of 32. Looking at the driver code, it appears this can already be reached by the driver. The max gain product (a-gain * d-gain) is, according to the tuning file, a max of 4096 in fixed ISO mode, so it looks like we should already be capable of 32 a-gain and 128 d-gain. Whether other settings allow it to get that high I don't know.
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

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

Re: Long exposures

Sat Dec 14, 2013 11:54 am

Thanks for checking James! How does the gain value translate to ISO?

I've tried various settings and the highest ISO I can get is 1600 (with the above command using sports mode and 1 sec shutter speed). Manually setting anything higher than 1600 (or even setting 1600 in most exposure modes) seems to keep the ISO at 800 -- perhaps there is a limit somewhere else in the exposure modes?

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

Re: Long exposures

Sat Dec 14, 2013 2:20 pm

I meant to ask what the relationship was between gain and Iso was on Friday but forgot...
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

peewee2
Posts: 61
Joined: Sun Apr 14, 2013 7:04 pm

Re: Long exposures

Sun Dec 15, 2013 2:35 am

just doing the maths on JBeale's 6mm f1.8 lens, the lens collects 7.2 times as much light as the standard picam lens.
That's obviously means the camera is 7.2 times as fast as std. ie if the max ISO value that can be set is 1600, then the bigger lens gives an equivalent to an setting of ISO 12000.

Assuming the lens is correctly focused and if optically as good as the original, that must be the way to go.

JB, just how easy is it to replace the std lens?

Pete

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

Re: Long exposures

Sun Dec 15, 2013 3:01 am

peewee2 wrote:just doing the maths on JBeale's 6mm f1.8 lens, the lens collects 7.2 times as much light as the standard picam lens.
That's obviously means the camera is 7.2 times as fast as std. ie if the max ISO value that can be set is 1600, then the bigger lens gives an equivalent to an setting of ISO 12000.
Assuming the lens is correctly focused and if optically as good as the original, that must be the way to go.
JB, just how easy is it to replace the std lens?
"optically as good as the original" - not a chance. The original is a highly optimized extreme-aspheric design, and performance is impressive for such a small camera, as we know. The cheap so-called "megapixel" M12 lenses available are still useful for many applications, eg. security cameras, but they are not in the same class optically. If you just want *some* image, they do certainly do put more photons onto the sensor. Even these $90 lenses from Edmund Optics http://www.edmundoptics.com/imaging/ima ... enses/2589 don't seem to do as well, if I understand the lp/mm specs (haven't actually tried them).

I found it pretty easy to replace the lens, but you need some tools, to cut out a notch in the M12 lens holder to fit over the camera's tiny onboard flex cable. I used epoxy to hold it in place afterwards. Focus is critical and fiddly because a slight finger pressure on the lens can make the difference between in focus and way out of focus. Anyway if you want to try it there is a pretty detailed and illustrated set of instructions here: http://wiki.raspberrytorte.com/index.ph ... odifcation

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

Re: Long exposures

Sun Dec 15, 2013 9:25 am

peewee2 wrote:just doing the maths on JBeale's 6mm f1.8 lens, the lens collects 7.2 times as much light as the standard picam lens.
Going from f/2.9 to f/1.8 is 1.3 stops.

peewee2
Posts: 61
Joined: Sun Apr 14, 2013 7:04 pm

Re: Long exposures

Sun Dec 15, 2013 4:59 pm

>> Going from f/2.9 to f/1.8 is 1.3 stops.

yes, but the focal length is longer, so for the same f number the diameter is bigger
the f number is the ratio of the focal length to the diameter

3.6/2.9 = 1.24mm, 1.24 squared = 1.53
6/1.8= 3.33, 3.33*3.33= 11.11
11.11/1.53=7.2 times bigger - seven times as much light, seven times faster

which is why JBeale gets much better night time shots than is possible with the std lens

Pete

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

Re: Long exposures

Sun Dec 15, 2013 5:21 pm

peewee2 wrote:>> Going from f/2.9 to f/1.8 is 1.3 stops.

yes, but the focal length is longer, so for the same f number the diameter is bigger
the f number is the ratio of the focal length to the diameter
The reason to calculate the f number that way is that the light level decreases with the inverse square law (if that's correct English). To get f/2.8 on a tele you need a larger front element than on a normal. f/2.8 gives, in theory, the same exposure with any lens (same shutter speed and ISO) just because of the definition of the f-number you wrote down above.

In other words you're compensating a second time in your calculation for something that's already 'baked' into the f-number definition.

peewee2
Posts: 61
Joined: Sun Apr 14, 2013 7:04 pm

Re: Long exposures

Sun Dec 15, 2013 5:31 pm

>> "optically as good as the original" - not a chance.

JBeale,

looking at your posted night time pics, you get an acceptable image with the 6mm lens whereas I get next to nothing using the std lens, so like everything it's a trade off.
The trade is to run the std lens at ISO 1600 with high noise or run the 6mm lens at ISO 250 with low noise but a bit of blur.

Clearly in daylight the larger lens gives no benefit as the std lens give acceptable pics, but for night time pics, the larger lens seems the way to go.

Pete

peewee2
Posts: 61
Joined: Sun Apr 14, 2013 7:04 pm

Re: Long exposures

Sun Dec 15, 2013 6:29 pm

poing,

I cannot argue with your group think, swapping lenses on a film camera should produce acceptable exposure, but that is because film had a relatively wide operating exposure range, a negative 1 stop underexposed could generally be rescued in the printing process.
In the days before through lens metering photographers often got the exposure wrong, as I know from experience.

Back to the subject at hand, forget about f numbers.
If a lens has a surface area 7 times larger than the std lens, and if we assume that is does work as a lens, then 7 times as many photons will reach the CCD, and that means the software only need to set the ISO at 1/7 of the value reqd by the std lens

Pete

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

Re: Long exposures

Sun Dec 15, 2013 7:03 pm

peewee2 wrote:>> "optically as good as the original" - not a chance.
looking at your posted night time pics, you get an acceptable image with the 6mm lens whereas I get next to nothing using the std lens, so like everything it's a trade off.
The trade is to run the std lens at ISO 1600 with high noise or run the 6mm lens at ISO 250 with low noise but a bit of blur.
Sure, if that example looks OK for your purposes, then go for it. But note that the equivalent exposure to 1600 with f/2.9 stock lens, with my 6mm f/1.8 lens is not ISO 250. To be exact, the difference in lens light throughput is 1.3761 stops, for a linear light factor of 2.596 times more light, meaning the equivalent speed is ISO 616.

If you're willing to put up with more blur, you can go even faster to a f/1.4 lens, that is a 2.1 stop advantage over the stock lens with a linear factor of 4.291 times more light. That would bring you from ISO 1600 to ISO 373.

If you want to experiment with exposure ratios at different f-stop settings, here is an online calculator: http://imaginatorium.org/stuff/stops.htm

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

Re: Long exposures

Sun Dec 15, 2013 7:39 pm

peewee2 wrote:poing,

I cannot argue with your group think
No, it's a very large group I belong to ;-) I'd advice you to read some more about photography, in particular about the use of handheld light meters. Maybe then you'll see.

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

Re: Long exposures

Tue Dec 17, 2013 9:02 am

poing wrote:
peewee2 wrote:poing,

I cannot argue with your group think
No, it's a very large group I belong to ;-) I'd advice you to read some more about photography, in particular about the use of handheld light meters. Maybe then you'll see.
On the other hand don't forget that CCD's work completely differently to film...
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

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

Re: Long exposures

Tue Dec 17, 2013 11:35 am

jamesh wrote:
poing wrote:
peewee2 wrote:poing,

I cannot argue with your group think
No, it's a very large group I belong to ;-) I'd advice you to read some more about photography, in particular about the use of handheld light meters. Maybe then you'll see.
On the other hand don't forget that CCD's work completely differently to film...
There are differences and similarities. One difference is that with digital you have instant feedback on the exposure so anyone that thinks exposure at a certain f-number varies proportionally with the diameter of the entrance pupil can check it immediately using any digital camera with exchangeable lenses. With well designed equipment the only difference can be the T-stop (=transmission).

peewee2
Posts: 61
Joined: Sun Apr 14, 2013 7:04 pm

Re: Long exposures

Sat Dec 21, 2013 1:21 am

Poing
I Think what you say may be true for a particular camera system, the manufacturer designs each lens to be interchangeable and fudges the appeture sizes to make your theory work.

That is not true for lenses of different type, if that were true then the pinoir would pass the same amount of light as the normal lens.

So its a much more complicated equation, you have to take into account refractive index, optical coating, field of view plus other factors.

The bottom line is a bigger lens will receive more light, so the light reaching the ccd will be greater and will allow the ccd to be used at a lower noise level.

Ask the wise old owl why his eyes are so big

Pete

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

Re: Long exposures

Sat Dec 21, 2013 3:41 pm

It's not 'my theory', it's stuff I learned at the photo academy where I spent four years learning to become a professional photographer, which has been my day job for the last 30 years. It's 'general photographic knowledge'. If you look at jbeale's later answer you see he comes to the exact same value of 1.3 stops I mentioned.

Let me try to explain: the f-number is based on mathematics, as you said the relation of the focal length and the diameter of the front element, and gives the theoretical amount of light falling on the sensor assuming a certain fixed light level. Therefore a smaller or larger front element is already calculated into the maximum f-number.

To get the exact amount of light falling on the sensor you also have to allow for transmission losses; light lost due to reflection inside the lens, opacity of the used glass and coatings. When you've done that you have the so-called T-stop of the lens, which is always slightly higher than the f-stop, but not much. T-stops are generally used in high-end analog film making as it's not as easy to change the exposure after the fact and the production costs are usually sky high.

More practical, back to the handheld lightmeter. Have you ever seen one of those? Did you ever have to dial in the size of the front element of the lens? Still they work with all cameras.

User avatar
rleyden
Posts: 71
Joined: Thu Jun 14, 2012 2:17 am

Re: Long exposures

Sun Dec 22, 2013 7:52 pm

poing wrote:More practical, back to the handheld lightmeter. .
Hey, poing. Speaking of lightmeters. Is there any hope a using a lightmeter to automatically set exposures on a Rpi camera in true night conditions?
I'm asking from two separate but related personal perspectives. I built a lightmeter for my greenhouse using a photodiode and an AD converter (I already was using a Make controller board that had analog inputs). It was amazingly easy to build and I played around with extending the dynamic range to include night time, even though that was irrelevant to the greenhouse. However, I didn't push too far into low light because I realized it was going to be complicated cover a dynamic range of over a million with a linear detector with 1024 bits. But, as far I could tell sensitivity wasn't a problem. I have already added the Adafruit AD kit to one of my RPi's, so adding a lightmeter would be easy.

The second perspective is that I bought a Canon S5 on Ebay to use as webcam because of its USB shutter control and CHDK programming. (tip: mid to high end consumer grade cameras now glut Ebay since the smart phone era.). I've taken great time-lapse sequences sunset through late-night with a relatively simple CHDK program. Of course the S5 has an iris but I'm guessing in this context that just means sharper daytime pictures. I'd like to do similar things with the RPi camera.

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

Re: Long exposures

Mon Dec 23, 2013 12:31 pm

If the light sensor is sensitive enough, why not? You need to use incident metering, where the light sensor is aimed at the light source (placed at the position of the subject if the light there is different from where the Pi is placed) and then work out the relation between the reading and exposure. If you use reflected metering the readings will become inaccurate based on the specific (changing) content of the scene and specific light distribution, where the Pi camera already has it built-in so that would be a useless exercise.

But then, the max the Pi will go is .97 sec @ ISO 1600 using the command:

Code: Select all

raspistill -ss 970000 -ex sports -t 10000 -o long.jpg
if you use a shorter evaluation time than -t 10000 the camera will not go all the way up to ISO 1600 and if you use a specific ISO setting it will max out at ISO 800. Also other -ex settings will max out at ISO 800. Therefore if you use a lightmeter to set manual exposure you won't be able to go past -ss 970000 ISO 800.

User avatar
rleyden
Posts: 71
Joined: Thu Jun 14, 2012 2:17 am

Re: Long exposures

Mon Dec 23, 2013 4:34 pm

poing wrote: But then, the max the Pi will go is .97 sec @ ISO 1600 using the command:

Code: Select all

raspistill -ss 970000 -ex sports -t 10000 -o long.jpg
.
Thanks for the answer. Maybe I should have started with a question that was more on topic with this thread.

I already tried the setting you suggested and it works somewhat better for twilight and is therefore useful for that. However, leaving the camera with that setting gives totally washed out daytime images. If it was mentioned in this thread how to get useful images with the full range of light conditions with one setting or script, I missed it. Is there such a setting?

And, I agree with the point that given the Pi camera limitations the "-ex sports" trick will, at best, add a couple f-stops. That translates into only an extra 10 minutes or so in a sunset time lapse sequence. So, perhaps I'm just trying to better understand what's possible. I follow the camera Forum sporadically and have come away with a confused view. Some of the impossible became possible while some of the initial feature-set remain out of reach.

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

Re: Long exposures

Mon Dec 23, 2013 5:38 pm

If you're using data from a light meter the shutter speed will not be stuck at .97 sec, so the images should not be washed out.

The '-ex Sports' trick will only add one stop. You could make a script that evaluates the light meter and/or exif data from the last image and when it reaches -ss 970000 ISO 800 switches to '-ex Sports'. You need to pinpoint that closely for otherwise you'll see an exposure change when shifting from your incident lightmeter to the reflected metering of the Pi Camera. That said it's indeed only a few minutes extra when the sun goes down, on the other hand it's often the most interesting time.

All in all the Pi Camera is not the low-light king by any stretch of imagination. You can also up the gain in post when the light is down and see if that gives acceptable results.

Return to “Camera board”