Auto exposure algorithm for shooting - auto iso, ae (autoexpo.mo)

Started by pravdomil, July 20, 2013, 10:19:10 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

pravdomil

Quote from: Audionut on August 16, 2013, 05:18:36 AM
If you enable in Av/Tv modes, couldn't you apply the maths from a fixed (user set) aperture/shutter?
well we can't change aperture in TV and shutter in Av (fighting with Canon) !

definitely I left this idea until there will be some clear and realizable algorithm

now I have to fix 5D3 lag, add EC curve, round ISO values, maybe option to attach main dial and speed dial to some conf value

nanomad

EOS 1100D | EOS 650 (No, I didn't forget the D) | Ye Olde Canon EF Lenses ('87): 50 f/1.8 - 28 f/2.8 - 70-210 f/4 | EF-S 18-55 f/3.5-5.6 | Metz 36 AF-5

pravdomil


nanomad

Yes, and a bit of spare time (int16, 20.000 addresses at a time)
EOS 1100D | EOS 650 (No, I didn't forget the D) | Ye Olde Canon EF Lenses ('87): 50 f/1.8 - 28 f/2.8 - 70-210 f/4 | EF-S 18-55 f/3.5-5.6 | Metz 36 AF-5

TheUnkn0wn

How to get AE_VALUE the easy way

1. Search for "***** copyOlcDataToStorage DataSizeOver Group0"
2. Go to its definition (as seen below)



3. Look above it you will see a value, in the example its 0x367B4
4. Pointer to EXPO_COMP = 0x367B4+0x1C


#define EXPO_COMP (*(int16_t*)(0x367B4+0x1C))
#define AE_VALUE (EXPO_COMP-1) * 8 / 2048


Done. ;)


nanomad

Disassemble it and  you'll see it uses that struct offset. Now we need to map that struct as it seems fairly important
EOS 1100D | EOS 650 (No, I didn't forget the D) | Ye Olde Canon EF Lenses ('87): 50 f/1.8 - 28 f/2.8 - 70-210 f/4 | EF-S 18-55 f/3.5-5.6 | Metz 36 AF-5

pravdomil

I want to find bright value for each sensor, but it seems that they are not stored nearby EXPO_COMP.

nanomad

EOS 1100D | EOS 650 (No, I didn't forget the D) | Ye Olde Canon EF Lenses ('87): 50 f/1.8 - 28 f/2.8 - 70-210 f/4 | EF-S 18-55 f/3.5-5.6 | Metz 36 AF-5

TheUnkn0wn

I didn't know there was an IRC channel  ???

What's the channel?



1%

Any point to finding expo comp in addition to AE Value? I think AE_Value itself can be found in a similar way.


Why #define AE_VALUE (EXPO_COMP-1) * 8 / 2048? All cameras have AE_VALUE that doesn't need this and matches the on screen meter.

Audionut

Having problems trying to compile with the latest changes.

magiclantern@magiclantern-VirtualBox:~/magic-lantern/modules$ make
make -C  ../modules/autoexpo
make[1]: Entering directory `/home/magiclantern/magic-lantern/modules/autoexpo'
[ CC       ]   autoexpo.o
[ MODULE   ]   autoexpo.mo
[ STRIP    ]   autoexpo.mo
[ EXPORTS  ]   autoexpo.sym
00000550 autoexpo_deinit
000006e4 autoexpo_keypress
00000708 autoexpo_init
[ DEPENDS  ]   autoexpo.dep
Will NOT load on:
    5D3 (advanced_mode)
Not checked (compile ML for these cameras first):
    100D, 1100D, 40D, 500D, 50D, 550D, 5D2, 5DC, 600D, 60D, 650D, 6D, 700D, 7D, EOSM
make[1]: *** [autoexpo.dep] Error 1
make[1]: Leaving directory `/home/magiclantern/magic-lantern/modules/autoexpo'
make: *** [autoexpo] Error 2
magiclantern@magiclantern-VirtualBox:~/magic-lantern/modules$


edit:  Got it working fine for 5D3
https://bitbucket.org/pravdomil/autoexpo-module/pull-request/1/fixes-for-5d3/diff

I know there was some discussion about this, but I can't remember where.  Shouldn't this,

static int get_ec(int bv){
    int offset = ec_off;
    if(lock_iso){
        int valid = RAW2AV(lens_info.raw_aperture_min) - av_min;
        if(valid > 0) offset += valid;
    }
    return COERCE(ec - (MIN(bv - offset, 0) * ec_step) / 10, ec_min, ec_max);
}


Be formatted like so?


static int get_ec(int bv)
{
    int offset = ec_off;
    if(lock_iso)
    {
        int valid = RAW2AV(lens_info.raw_aperture_min) - av_min;
        if(valid > 0) offset += valid;
    }
    return COERCE(ec - (MIN(bv - offset, 0) * ec_step) / 10, ec_min, ec_max);
}


Can you link EC to a scroll dial?
This way it can be adjusted on the fly rather then changing via menu.

Audionut

The EC curve is doing my head in.  It would be far simpler for the end user if there were just some basic conditions.

User selects EC+

Try to EC with shutter

if fail, try to EC with aperture

if fail, try to EC with ISO.


User selects EC-

Try to EC with ISO,

if fail, try to EC shutter,

if fail, try to EC with aperture



With EC linked to scroll wheel, user selects EC for entire EV range.
User can then make EC adjustments on the fly, rather then using some predetermined curve that has no respect for the dynamic range of the scene.

pravdomil

Quote from: 1% on August 19, 2013, 02:58:15 AM
Any point to finding expo comp in addition to AE Value? I think AE_Value itself can be found in a similar way.
Why #define AE_VALUE (EXPO_COMP-1) * 8 / 2048? All cameras have AE_VALUE that doesn't need this and matches the on screen meter.
https://bitbucket.org/hudson/magic-lantern/pull-request/144/autoexpo-module/activity#comment-408042

Quote from: Audionut on August 19, 2013, 07:41:32 AM
The EC curve is doing my head in.  It would be far simpler for the end user if there were just some basic conditions.
well this implementation is for me easier, you can do it and send me pull request

Quote from: Audionut on August 19, 2013, 03:41:39 AM
Can you link EC to a scroll dial?
This way it can be adjusted on the fly rather then changing via menu.
in TODO list

Quote from: Audionut on August 19, 2013, 07:41:32 AM
User can then make EC adjustments on the fly, rather then using some predetermined curve that has no respect for the dynamic range of the scene.
well it will be completely fixed after we found all brightness sensors values
I have this idea there will be 3 choices
Image that you are shooting from your room throw window.
1. I don't want any overexposure (like ETTR) - I want to shoot something outside
2. Balanced over and underexposure - I want shoot something outside and inside
3. I want to shoot dark areas - I want shoot picture on wall near the window
or you can shoot with DualISO :)

Audionut

Quote from: pravdomil on August 19, 2013, 09:59:15 AM
well this implementation is for me easier, you can do it and send me pull request

I must have been doing something wrong before, or it was a result of my incorrect code changes, or both.  It makes more sense now.

Quote from: pravdomil on August 19, 2013, 09:59:15 AM
in TODO list

Cheers.  This will be very handy.

Quote from: pravdomil on August 19, 2013, 09:59:15 AM
well it will be completely fixed after we found all brightness sensors values
I have this idea there will be 3 choices
Image that you are shooting from your room throw window.
1. I don't want any overexposure (like ETTR) - I want to shoot something outside
2. Balanced over and underexposure - I want shoot something outside and inside
3. I want to shoot dark areas - I want shoot picture on wall near the window
or you can shoot with DualISO :)

To be honest, I think it's best to keep this module simply what it does best.
EC is the photographers control over middle exposure.  It allows the photographer to compensate for situations like you have described.

As soon as you only concern with highlight protection, you no longer care about "correct" exposure.  ETTR should remain separate.
But it's your module ;)

Thanks for your work.  This is dragging me back from full manual mode back to semi-auto :)

I have a test build for 5D3 here

pravdomil

Quote from: Audionut on August 19, 2013, 10:27:15 AM
EC is the photographers control over middle exposure.  It allows the photographer to compensate for situations like you have described.
As soon as you only concern with highlight protection, you no longer care about "correct" exposure.  ETTR should remain separate.

Sure, it will be only a option, there will be possibility to shoot with middle range and custom EC.
Probably I will call it Auto EC :D


nanomad

Quote from: Audionut on August 19, 2013, 10:27:15 AM
EC is the photographers control over middle exposure.  It allows the photographer to compensate for situations like you have described.

Couldn't agree more. We need to come up with a name for the EC curve that explains its rationale
EOS 1100D | EOS 650 (No, I didn't forget the D) | Ye Olde Canon EF Lenses ('87): 50 f/1.8 - 28 f/2.8 - 70-210 f/4 | EF-S 18-55 f/3.5-5.6 | Metz 36 AF-5

1%

Real AE_VALUE has values like this: F301

F3 would be like -3 expo and 01/etc is whether manual or auto exposure is used. It is int8... value must be matching your calcuation since its working everywhere else and gets reasonably good expo.

Audionut

Quote from: nanomad on August 19, 2013, 04:58:23 PM
Couldn't agree more. We need to come up with a name for the EC curve that explains its rationale

Currently, you can only curve it to the Luminance Value.  This has no respect for dynamic range or other scene conditions. 

Scene luminance value alone does not determine dynamic range or the midtone point.  Both of which are the factors in a photographer determining a correct level of EC.  If a scene has a very large dynamic range, you might apply a small negative EC to capture the highlights.  You might also instead decide to apply a small positive EC, to bring skin tones from the shadows into a correct exposure without regard for the highlights.  Adjusting the midtone.

In scenes with very little dynamic range, you might (should) apply a positive EC to push the exposure to the right hand side of the histogram.

Again, both of these cases cannot be determined by the scene luminance value alone.  So to map EC to luminance does not make sense.

The only other name I can think of for EC, is midtone correction.  Effectively this is what it controls, even though we can use it to other advantages (ETTR).

edit:  If the white point can be found outside of LV, now we're talking :)  Automatic positive EC (ETTR) in low dynamic range scenes, all in realtime without LV!  That's pretty awesome.  I don't have to think about exposure, I can concentrate on composition for instance.

Also midtone/shadow priority in large dynamic range scenes.
Quote2. Balanced over and underexposure - I want shoot something outside and inside

pravdomil

Quote from: 1% on August 19, 2013, 05:15:41 PM
Real AE_VALUE has values like this: F301
F3 would be like -3 expo and 01/etc is whether manual or auto exposure is used. It is int8... value must be matching your calcuation since its working everywhere else and gets reasonably good expo.

could you send me some instruction how can I find it via Ida like TheUnkn0wn posted?

nanomad

Easy enough. Correct AE_VALUE is just EXPO_COMP + 1 taken as int8_t (offset 0x1D instead of 0x1C)

E.g. on the 650D:

#define EXPO_COMP (*(int16_t*)0x366d4)
#define AE_VALUE (*(int8_t*)0x366d5)


EXPO COMP is now useless. 366D4 is another int8_t showing when metering is active in M mode
EOS 1100D | EOS 650 (No, I didn't forget the D) | Ye Olde Canon EF Lenses ('87): 50 f/1.8 - 28 f/2.8 - 70-210 f/4 | EF-S 18-55 f/3.5-5.6 | Metz 36 AF-5