cascafico
Posts: 6
Joined: Fri Dec 15, 2017 6:24 pm

raspistill exposure compensation

Mon Dec 18, 2017 8:44 am

Anybody here can post a working example?

I had no success in testing this parameter, nor ImageMagik-identify reports any exif data for it.

I have a portion of frame which is covered by overexposed snow which I'm trying to resolve with the following command:

> raspistill -n -t 1000 -ex auto -roi 0.6,0.2,0.3,0.3 --ev -9 -o matajur.jpg

> identify -verbose matajur.jpg | grep posure
exif:ExposureMode: 0
exif:ExposureProgram: 3
exif:ExposureTime: 1578/1000000

and resulting images shows no differences with or w/o "-ev -9"

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 9069
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: raspistill exposure compensation

Mon Dec 18, 2017 10:05 am

One could add the ExposureBiasValue tag into the EXIF, but that bit of plumbing isn't present in the firmware as it gets converted between a number of different representations, and the field internally is also used for other things (it's a parameter adjusting the target brightness for the AE/AGC).

As stated in the help text

Code: Select all

-ev, --ev	: Set EV compensation - steps of 1/6 stop
So your -9 should be -1.5 EV, and that should be noticable. The permitted range is +/-24.
Do remember that the exposure compensation doesn't allow the exposure/gain to go outside the programmed limits, which for the auto mode are 66ms and x8 gain.

Running the commands

Code: Select all

raspistill -n -t 1000 -ex auto -roi 0.6,0.2,0.3,0.3 --ev -9 -o ev-9.jpg
raspistill -n -t 1000 -ex auto -roi 0.6,0.2,0.3,0.3 -o ev0.jpg
on my Pi here gives ev-9.jpg with
exif:ExposureTime: 32974/1000000
exif:ISOSpeedRatings: 125
vs ev0.jpg with
exif:ExposureTime: 16300/1000000
exif:ISOSpeedRatings: 100
which looks about right.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

cascafico
Posts: 6
Joined: Fri Dec 15, 2017 6:24 pm

Re: raspistill exposure compensation

Tue Dec 19, 2017 11:21 am

6by9 wrote:
Mon Dec 18, 2017 10:05 am
Running the commands

Code: Select all

raspistill -n -t 1000 -ex auto -roi 0.6,0.2,0.3,0.3 --ev -9 -o ev-9.jpg
raspistill -n -t 1000 -ex auto -roi 0.6,0.2,0.3,0.3 -o ev0.jpg
on my Pi here gives ev-9.jpg with
exif:ExposureTime: 32974/1000000
exif:ISOSpeedRatings: 125
vs ev0.jpg with
exif:ExposureTime: 16300/1000000
exif:ISOSpeedRatings: 100
which looks about right.
Thanks for your comprehensive answer. My recorded values are:

exif:ExposureTime: 1711/1000000 for -ev 0
exif:ExposureTime: 1257/1000000 for -ev -24

which are pretty close.

I think the problem is that raspistill is measuring light always on the whole frame, never mind the snowy roi which covers upper left corner.

the only way I've found to resolve mountain detail is setting shutter speed manually
Image

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 9069
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: raspistill exposure compensation

Tue Dec 19, 2017 11:47 am

cascafico wrote:
Tue Dec 19, 2017 11:21 am
Thanks for your comprehensive answer. My recorded values are:

exif:ExposureTime: 1711/1000000 for -ev 0
exif:ExposureTime: 1257/1000000 for -ev -24

which are pretty close.

I think the problem is that raspistill is measuring light always on the whole frame, never mind the snowy roi which covers upper left corner.

the only way I've found to resolve mountain detail is setting shutter speed manually
I should have asked before, is this a V1 or V2 camera?
Yes it is metering on the entire frame, but that shouldn't matter when setting ev as it is all relative (as long as you don't hit the exposure mode limits). There is an option to alter the metering area, but I've never tried it on a Pi. You can use the metering modes (-mm) to alter how the metering algorithm is weighting regions.

You don't say what the ISO values are for those frames, but I'm surprised that it doesn't move the exposure time more as that is almost always done in preference to ISO (gain).
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

cascafico
Posts: 6
Joined: Fri Dec 15, 2017 6:24 pm

Re: raspistill exposure compensation

Tue Dec 19, 2017 1:18 pm

6by9 wrote:
Tue Dec 19, 2017 11:47 am
I should have asked before, is this a V1 or V2 camera?
Yes it is metering on the entire frame, but that shouldn't matter when setting ev as it is all relative (as long as you don't hit the exposure mode limits). There is an option to alter the metering area, but I've never tried it on a Pi. You can use the metering modes (-mm) to alter how the metering algorithm is weighting regions.

You don't say what the ISO values are for those frames, but I'm surprised that it doesn't move the exposure time more as that is almost always done in preference to ISO (gain).
Camera is a V2.1 and I didn't mention ISOs because they are both 100.

Futher tests:
pictures taken whitout -roi option looks consistent with ev values. ie: -ev -24 is much more darker than -ev 0
pictures taken with -roi option have same brightness, never mind -ev I set (-24, 0, 24)

I guess that if I want to get detail of my upper right snowy corner, I need to shot whole frame underexposing and then crop.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 9069
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: raspistill exposure compensation

Tue Dec 19, 2017 3:12 pm

I had been using a V1, but retesting on a V2 seems to still behave correctly.

Adding the -set option prints out the exposure and gains as they adapt.
Using "raspistill -t 1000 -ex auto -roi 0.6,0.2,0.3,0.3 -ev 0 -o ev0.jpg -set" they converge on
mmal: Exposure now 62979, analog gain 440/256, digital gain 257/256
Using "raspistill -t 1000 -ex auto -roi 0.6,0.2,0.3,0.3 -ev -24 -o ev-24.jpg -set" they converge on
mmal: Exposure now 29840, analog gain 256/256, digital gain 259/256
So x2.11 on exposure time, and x1.718 on gain. Overall x3.62, so not far off the x4 difference I'd expect for EV -4.

Trying "raspistill -t 1000 -ex auto -roi 0.6,0.2,0.3,0.3 -ev 24 -o ev24.jpg -set" they converge on
mmal: Exposure now 62922, analog gain 1772/256, digital gain 259/256
Exposure time hasn't changed wrt to ev0 as it is at the maximum permitted by the exposure mode, but 1772/440 = x4.02, so pretty much spot on.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 9069
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: raspistill exposure compensation

Tue Dec 19, 2017 3:15 pm

Ah, I've just noticed the minimum values in the tuning - they'll go down to 1ms by default and no lower. Your quoted values were
exif:ExposureTime: 1711/1000000 for -ev 0
exif:ExposureTime: 1257/1000000 for -ev -24
so already at the minimum. I'll have a chat with a colleague to see if there is a reason for this apparently very high minimum value. I'm sure other tunings have taken it lower.
Sorry, I think I'm talking twaddle. They should go down to 0.1ms or 100usecs, so you're still 10 times above that limit.
I've just proved it to myself too by pointing the camera at a very bright light and getting down to exposure of 161us.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

cascafico
Posts: 6
Joined: Fri Dec 15, 2017 6:24 pm

Re: raspistill exposure compensation

Wed Dec 20, 2017 9:27 am

6by9 wrote:
Tue Dec 19, 2017 3:15 pm
exif:ExposureTime: 1711/1000000 for -ev 0
exif:ExposureTime: 1257/1000000 for -ev -24
Finally I noticed ev works... , thanks for suggesting -set option (btw, is the applied exposure the last one listed?).
It's likely ev option worked also in the first tests I reported yesterday; maybe snow brightness was way out dynamic range to realize at a glance that an underexposure was applied.

raspistill -n -t 1000 -w 360 -h 240 -ev -24 -roi 0.6,0.2,0.3,0.3 -set -o ev-23.jpg
Exposure now 1276, analog gain 256/256, digital gain 257/256
exif:ExposureTime: 1276/1000000
Image

raspistill -n -t 1000 -w 360 -h 240 -ev 0 -roi 0.6,0.2,0.3,0.3 -set -o ev0.jpg
Exposure now 1767, analog gain 258/256, digital gain 256/256
exif:ExposureTime: 1767/1000000
Image

raspistill -n -t 1000 -w 360 -h 240 -ev 24 -roi 0.6,0.2,0.3,0.3 -set -o ev23.jpg
Exposure now 6739, analog gain 256/256, digital gain 257/256
exif:ExposureTime: 6739/1000000
Image

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 9069
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: raspistill exposure compensation

Thu Dec 21, 2017 9:58 am

So I'm a little surprised that -ev doesn't make a more significant impact, but your scene is pretty much saturated in the whole top half which limits the effect changing the average target brightness value will have.
I'd suggest trying "-mm backlit" to reduce the effect that the background has on the exposure calcs. As a potential alternative, "-mm spot" will bias the centre most heavily which may also work in your case.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Camera board”