Author Topic: Auto exposure algorithm for shooting - auto iso, ae (autoexpo.mo)  (Read 238421 times)

pravdomil

  • Member
  • ***
  • Posts: 166
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #100 on: August 16, 2013, 11:59:18 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

  • Administrator
  • Hero Member
  • *****
  • Posts: 2918
  • All your websites are belong to us
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #101 on: August 17, 2013, 05:25:01 PM »
Ported to the 650D! Working beautifully :D
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

  • Member
  • ***
  • Posts: 166
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #102 on: August 17, 2013, 08:13:43 PM »
nice, how do you found it? mem_spy?

nanomad

  • Administrator
  • Hero Member
  • *****
  • Posts: 2918
  • All your websites are belong to us
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #103 on: August 17, 2013, 08:28:06 PM »
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

  • Freshman
  • **
  • Posts: 60
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #104 on: August 17, 2013, 09:29:05 PM »
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

Code: [Select]
#define EXPO_COMP (*(int16_t*)(0x367B4+0x1C))
#define AE_VALUE (EXPO_COMP-1) * 8 / 2048

Done. ;)

pravdomil

  • Member
  • ***
  • Posts: 166
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #105 on: August 17, 2013, 09:50:42 PM »

nanomad

  • Administrator
  • Hero Member
  • *****
  • Posts: 2918
  • All your websites are belong to us
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #106 on: August 17, 2013, 09:54:23 PM »
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

  • Member
  • ***
  • Posts: 166
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #107 on: August 17, 2013, 09:59:09 PM »
I want to find bright value for each sensor, but it seems that they are not stored nearby EXPO_COMP.

nanomad

  • Administrator
  • Hero Member
  • *****
  • Posts: 2918
  • All your websites are belong to us
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #108 on: August 17, 2013, 10:16:18 PM »
Get on IRC, I've got a few ideas :D
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

  • Freshman
  • **
  • Posts: 60
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #109 on: August 17, 2013, 11:48:31 PM »
I didn't know there was an IRC channel  ???

What's the channel?

pravdomil

  • Member
  • ***
  • Posts: 166
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #110 on: August 18, 2013, 12:27:10 AM »
#magiclantern@freenode.net


1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #112 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.

Audionut

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3657
  • Blunt and to the point
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #113 on: August 19, 2013, 03:41:39 AM »
Having problems trying to compile with the latest changes.

Code: [Select]
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,

Code: [Select]
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?

Code: [Select]
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3657
  • Blunt and to the point
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #114 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.

Code: [Select]
User selects EC+

Try to EC with shutter

if fail, try to EC with aperture

if fail, try to EC with ISO.

Code: [Select]
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

  • Member
  • ***
  • Posts: 166
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #115 on: August 19, 2013, 09:59: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

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

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

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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3657
  • Blunt and to the point
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #116 on: August 19, 2013, 10:27: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.

in TODO list

Cheers.  This will be very handy.

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

  • Member
  • ***
  • Posts: 166
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #117 on: August 19, 2013, 10:44:24 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

pravdomil

  • Member
  • ***
  • Posts: 166
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #118 on: August 19, 2013, 11:56:00 AM »

nanomad

  • Administrator
  • Hero Member
  • *****
  • Posts: 2918
  • All your websites are belong to us
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #119 on: August 19, 2013, 04:58:23 PM »
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%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #120 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.

Audionut

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3657
  • Blunt and to the point
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #121 on: August 19, 2013, 05:38:10 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.
Quote
2. Balanced over and underexposure - I want shoot something outside and inside

pravdomil

  • Member
  • ***
  • Posts: 166
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #122 on: August 20, 2013, 11:14:03 AM »
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

  • Administrator
  • Hero Member
  • *****
  • Posts: 2918
  • All your websites are belong to us
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #123 on: August 20, 2013, 12:10:21 PM »
Easy enough. Correct AE_VALUE is just EXPO_COMP + 1 taken as int8_t (offset 0x1D instead of 0x1C)

E.g. on the 650D:
Code: [Select]
#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

pravdomil

  • Member
  • ***
  • Posts: 166
Re: Auto exposure algorithm for shooting - auto iso, ae
« Reply #124 on: August 20, 2013, 12:53:25 PM »