supplierdeeply

Getting live view exposure (was Re: Improving CHDK ND filter support)

  • 18 Replies
  • 10661 Views
*

Offline reyalp

  • ******
  • 11583
Advertisements
I tested the get_current_exp function on elph130 bit. All the values seem to be the currently active values, so the Tv reflects what the live view is using, even in half press. I didn't check while a shot was actually in progress. The gain value isn't an sv96 value, I saw values ranging from -155 (aimed directly at a light) to 192 (very low light)

There's a value after gain which comes from a function referencing ImgPixel.c. It was always zero in my testing.

Getting live exposure values without needing half press might be useful.
« Last Edit: 12 / August / 2018, 23:48:22 by reyalp »
Don't forget what the H stands for.

Re: Re: Improving CHDK ND filter support
« Reply #1 on: 06 / August / 2018, 05:17:25 »
Getting live exposure values without needing half press might be useful.
Very useful!

A "live" exposure meter is the final piece of making my GUI 3.0 code useful.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Re: Improving CHDK ND filter support
« Reply #2 on: 12 / August / 2018, 22:27:45 »
I checked in the finsig_vxworks and finsig_dryos changes for get_nd_value, get_current_nd_value and get_current_exp. These aren't 100% verified, but I checked the disassembly for a pretty good sample and didn't find any issues.
I'm starting to get excited to look at the GUI 3.0 code again.

The gain value isn't an sv96 value, I saw values ranging from -155 (aimed directly at a light) to 192 (very low light)
Wouldn't it be nice if that value simply reflects under & over exposure amounts at the current Tv, Av, Sv, NDfilter, and EvAdjust settings?  Implementing a live GUI exposure meter becomes a simple project at that point.

If I get a few moments, I'll play with it unless someone else chimes in first.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 11583
Re: Re: Improving CHDK ND filter support
« Reply #3 on: 12 / August / 2018, 23:33:23 »
Wouldn't it be nice if that value simply reflects under & over exposure amounts at the current Tv, Av, Sv, NDfilter, and EvAdjust settings?
Based on the the values I saw, I don't think this is the case. I'd guess it's more like a lower level representation of sensor gain, but that's pretty much a wag.

There's a lot of strings referencing CDSGain that might provide clues. There is a function  SetCDSGainStep which prints a string "SetCDSGainApex %d" which might hint at a conversion.

get_current_exp fills an array of 16 bit values: Av, Tv, "Gain", something from "ImgPixel.c", the ND value (ND + Iris cams only) and one more value that's (often?) hardcoded to 0.

For interactive testing with chdkptp, it's easier to call the functions directly with call_func_ptr so you don't have to deal with allocating memory for the array.

edit:
Split this to a new topic. The only connection to the ND project was that it was a useful path to finding the current ND value.
« Last Edit: 16 / September / 2018, 01:18:55 by reyalp »
Don't forget what the H stands for.


*

Offline reyalp

  • ******
  • 11583
Re: Getting live view exposure (was Re: Improving CHDK ND filter support)
« Reply #4 on: 09 / September / 2018, 21:22:57 »
Here's a preliminary patch that exposes the GetCurrent* functions to script, as
get_current_tv96 and get_current_av96.
Stubs rebuild is needed for GetCurrentShutterSpeed but it should be found on all platforms. GetCurrentAvValue was already in stubs.

I renamed the CHDK versions of these functions to shooting_get_current_av96 and shooting_get_current_tv96 for consistency.

Some observation:
On A540, calling get_current_tv96() while the sensor is off (in playback or display off mode) appears to cause crashes when the sensor is turned on again. SX160 does not suffer from this.

get_current_tv96() does not obviously ever reflect the shutter speed used for a shot. I checked after half press, after the remote hook, and after the raw hook. get_current_av96() does appear to match the shot AV value in half press.

I haven't done any further investigation of the CDSGain / ISO. With a known BV from half press we should be able to determine if there is a simple relationship.
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 11583
Re: Getting live view exposure (was Re: Improving CHDK ND filter support)
« Reply #5 on: 15 / September / 2018, 23:24:17 »
On A540, calling get_current_tv96() while the sensor is off (in playback or display off mode) appears to cause crashes when the sensor is turned on again. SX160 does not suffer from this.
D10 also doesn't have this problem, so I suspect it only applies old cameras, but unclear whether the cutoff is digic 2, vxworks, or something else.

There are variables that appear to reflect when the sensor is on, for example 0x54A0  on a540 (often referenced as 0x549C+4). It should be possible to add this to the sig finders (maybe via "Fail ImagerActivate(ErrorCode:%x)\r", but doesn't appear to exposed through a super easy event proc. Knowing whether the sensor is on might be useful in other contexts.
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 11583
Re: Getting live view exposure (was Re: Improving CHDK ND filter support)
« Reply #6 on: 16 / September / 2018, 01:32:18 »
The "ISO" value from get_current_exp seems to be an APEX96 offset from some fixed base SV96 value.
On A540, the base value seems to be equivalent to SV96 (real) 600
On elph180, it appears to be 795.

The offset value appears to be referred to as "DeltaGain" in the A540 firmware, from the eventproc ImgGainTool.GetGain

The way I found this was
half press to to get Bv
use Tv + Av - Bv = Sv to get the what the Sv value would be using the Bv from half press and the live view (current) Tv and Av.

Note the above is only valid if the the camera was able achieve "correct" exposure in half press. If it's pointed somewhere so dark the shutter hits the 1 sec auto exposure limit, the calculated Sv will be wrong.
The following chdkptp snippet is what I used on elph130.  The call_func_ptr values are the ImgGain.c and ImgPixel functions from get_current_exp. The ImgPixel one was always 0 in my testing.
Code: [Select]
!bv,sv,tv,av,dg,ug=con:execwait[[
p=require'propcase' press'shoot_half' repeat sleep(10) until get_shooting() return get_prop(p.BV),get_prop(p.SV),get_current_tv96(),get_current_av96(),call_func_ptr(0xFF916908),call_func_ptr(0xFF916E0C)
]]
esv=tv + av - bv
printf("tv=%d (%s) av=%d (%0.2f) bv=%d dg=%d esv=%d (%d) esv-dg=%d sv=%d (%d) ug=%d\n",
tv,exp.tv96_to_shutter_str(tv),
av,exp.av96_to_f(av),
bv,
dg,
esv,exp.sv96_to_iso(esv),esv-dg,
sv,exp.sv96_to_iso(sv),ug)

Making this usable will probably require a sig finder friendly way of finding the base value.
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 11583
Re: Getting live view exposure (was Re: Improving CHDK ND filter support)
« Reply #7 on: 06 / October / 2018, 21:18:45 »
I checked in the code for Lua get_current_av96 in trunk 5104, since it's useful for Av testing
« Last Edit: 06 / October / 2018, 23:51:46 by reyalp »
Don't forget what the H stands for.


*

Offline srsa_4c

  • ******
  • 3725
Re: Getting live view exposure (was Re: Improving CHDK ND filter support)
« Reply #8 on: 13 / October / 2018, 14:59:48 »
FWIW, I found a function named GetBaseSv (while I was looking for identifiable propcases in the M6 fw) and added it to the pre-d6 sigfinders. It is very likely not what you're after, I'm just putting this note here to avoid confusion.
It looks like the result of that function is put in a certain propcase in the same fw function that the sigfinders use (3 DebugAsserts followed by a bunch of SetPropertyCase calls).

*

Offline srsa_4c

  • ******
  • 3725
Re: Getting live view exposure (was Re: Improving CHDK ND filter support)
« Reply #9 on: 07 / November / 2018, 17:49:13 »
On A540, calling get_current_tv96() while the sensor is off (in playback or display off mode) appears to cause crashes when the sensor is turned on again. SX160 does not suffer from this.
D10 also doesn't have this problem, so I suspect it only applies old cameras, but unclear whether the cutoff is digic 2, vxworks, or something else.

There are variables that appear to reflect when the sensor is on, for example 0x54A0  on a540 (often referenced as 0x549C+4). It should be possible to add this to the sig finders (maybe via "Fail ImagerActivate(ErrorCode:%x)\r", but doesn't appear to exposed through a super easy event proc. Knowing whether the sensor is on might be useful in other contexts.
Attached diff is for finding the mentioned fw variable (I named it imager_active, suggestions for a better name are welcome). vx and dryos, t2 version is still to be done. I only checked some of the results, but the others also look reasonable.
Same variable causing different trouble here: https://chdk.setepontos.com/index.php?topic=11078.msg136913#msg136913

 

Related Topics