1.3 development proposal - exposure conversion functions - page 2 - General Discussion and Assistance - CHDK Forum supplierdeeply

1.3 development proposal - exposure conversion functions

  • 58 Replies
  • 25172 Views
*

Offline reyalp

  • ******
  • 14082
Re: Re: 1.3 development planning thread
« Reply #10 on: 24 / August / 2013, 14:18:19 »
Advertisements
I like phils proposal. I agree with lapser that the names should be lowercase, since that is consistent with almost everything that is already in the api.

In Lua, I supposed you could make the numerator optional, defaulting to 1. I love optional parameters. Personally, I would probably never use a numerator other than 1. The main thing this function would be used for is inputting fast shutter speeds in (1/sec) format. Do you have a scenario where you would need a numerator other than 1? For simplicity, this would be better for my uses:
2/3 ?
3/4 ?
It also lets you sue the same function for long exposures, since you can use, e.g. 120/1 for a 2 minute exposure.

I'm only fond of optional parameters where the behavior is fairly obvious. Assuming 1/x if there is only one number might fit the bill in this case, though putting the 1 in isn't much work.
Don't forget what the H stands for.

*

Offline lapser

  • *****
  • 1093
Re: Re: 1.3 development planning thread
« Reply #11 on: 24 / August / 2013, 15:26:57 »
In Lua, I supposed you could make the numerator optional, defaulting to 1. I love optional parameters. Personally, I would probably never use a numerator other than 1. The main thing this function would be used for is inputting fast shutter speeds in (1/sec) format. Do you have a scenario where you would need a numerator other than 1? For simplicity, this would be better for my uses:
2/3 ?
3/4 ?
It also lets you sue the same function for long exposures, since you can use, e.g. 120/1 for a 2 minute exposure.
2/3 and 3/4 never appear as shutter times on my cameras, or in EXIF data that I've ever seen. But I don't see any reason to eliminate the capability.

I do like having a denominator, so 120/1 is 120 seconds, instead of 120000000. Of course, then the denominator just becomes a scale factor, like I have in my current functions:

I doubt I would ever use usec_to_tv96. Instead, I would enter it as microseconds:

rational_to_tv96(msec,1000)

I don't like the name "rational" since it doesn't include the unit, which is seconds/d. How about:

rsec_to_tv96(n,d)
rsec= rational seconds. It goes with usec=microseconds.
===
Also, since both uBasic and Lua are in modules, wouldn't it be better to duplicate the code in both? That saves memory when scripts aren't running, and you don't need to add all the functions to the module export list. Do you need to be able to call the new functions from CHDK routines in addition to scripts?

And do we really need to add all new functions to uBasic? It seems obsolete with Lua available.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

Re: Re: 1.3 development planning thread
« Reply #12 on: 24 / August / 2013, 18:05:56 »
And do we really need to add all new functions to uBasic?
Yes,  I believe that we do.  Not every newbie with "get" Lua right away and many of them just want to do something simple with CHDK.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline srsa_4c

  • ******
  • 4451
Re: Re: 1.3 development planning thread
« Reply #13 on: 25 / August / 2013, 09:01:35 »
Yes,  I believe that we do.  Not every newbie with "get" Lua right away and many of them just want to do something simple with CHDK.
+ uBasic requires less memory, which can be significant on some cameras


*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: 1.3 development proposal - exposure conversion functions
« Reply #14 on: 31 / August / 2013, 03:02:38 »
I've added the conversion functions in revision 3052 (trunk).
I went with 'seconds_to_tv96(n,d)' instead of 'rational_to_sv96(n,d)' after discussion with reyalp and waterwingz on IRC.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

Re: 1.3 development proposal - exposure conversion functions
« Reply #15 on: 31 / August / 2013, 11:12:03 »
Updated :
http://chdk.wikia.com/wiki/Script_commands#APEX96_Conversion_Functions
http://chdk.wikia.com/wiki/CHDK_Scripting_Cross_Reference_Page#All_Scripting_Functions

Its consistent with the rest of the scripting documentation as its concise and not too useful.  I'll see if I can make it a bit better
Ported :   A1200    SD940   G10    Powershot N    G16

Re: 1.3 development proposal - exposure conversion functions
« Reply #16 on: 31 / August / 2013, 12:47:55 »
Wrote a little test script that I had planned to break into pieces and add to the wiki write-ups as examples.
Code: [Select]
--[[
@title APEX96
@param i ISO value
@default i 200
@param l Log
@default l 0
@range l 0 1
--]]
set_console_layout(0, 0, 44, 16)
print_screen(l)

sv96 = iso_to_sv96(i)
print("ISO "..i.." = SV96 "..sv96)
iso=sv96_to_iso(sv96)
print("SV96 "..sv96.." = ISO" , iso )

isom=iso_real_to_market(i)
isor=iso_market_to_real(i)
print("ISO "..i.." real  = ISO"..isom.." market")
print("ISO "..i.." market = ISO"..isor.." real")

sv96m=sv96_real_to_market(sv96)
sv96r=sv96_market_to_real(sv96)
print("SV96 "..sv96.." real = "..sv96m.." market")
print("SV96 "..sv96.." market = "..sv96r.." real")

fstop=5600
av96 = aperture_to_av96(fstop)
print("f"..(fstop/1000).."." ..((fstop%1000)/100).." = AV96 "..av96)
fstop = av96_to_aperture(av96)
print("AV96 "..av96.." = f"..(fstop/1000).."."..(fstop%1000)/100)

shutter=10000
tv96=usec_to_tv96(shutter)
print((shutter/1000000).."sec ".. (shutter/1000).." msec = "..tv96.." in apex96 units" )
shutter=tv96_to_usec(tv96)
print("TV96 "..tv96.." = "..(shutter/1000000).."sec ".. (shutter/1000).." msec")

n=1
d=60
tv96=seconds_to_tv96(n,d)
print(n.."/"..d.." = ", tv96, "in apex96 units" )
shutter=tv96_to_usec(tv96)
print("TV96 "..tv96.." = "..(shutter/1000000).."sec ".. (shutter/1000).." msec")
The edited resulting log file looks like this :
Code: [Select]
ISO 200 = SV96 576
SV96 576 = ISO 200
ISO 200 real  = ISO329 market        <--- really ?
ISO 200 market = ISO122 real         <--- can this be true ?
SV96 576 real = 645 market            <-- here too
SV96 576 market = 507 real            <-- and here
f5.6 = AV96 477
AV96 477 = f5.5                   <-- a slight rounding error
0sec 10 msec = 638 in apex96 units
TV96 638 = 0sec 9 msec          <-- more rounding tweaks needed
1/60 =  567 in apex96 units
TV96 567 = 0sec 16 msec
The rounding errors in Tv and Av conversions are easy to adjust in the script. 

But the output of the ISO real to market seems strange!  I would not have expected that big a different on my A1200.  Maybe I'm using the new functions incorrectly?
« Last Edit: 31 / August / 2013, 12:54:59 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 14082
Re: 1.3 development proposal - exposure conversion functions
« Reply #17 on: 31 / August / 2013, 13:06:27 »
But the output of the ISO real to market seems strange!  I would not have expected that big a different on my A1200.  Maybe I'm using the new functions incorrectly?
They look correct to me. The standard difference is 69 APEX96.

APEX96 to ISO (in whichever system) is 3.125*(2(APEX96/96))
Don't forget what the H stands for.


Re: 1.3 development proposal - exposure conversion functions
« Reply #18 on: 31 / August / 2013, 13:09:39 »
But the output of the ISO real to market seems strange!  I would not have expected that big a different on my A1200.  Maybe I'm using the new functions incorrectly?
They look correct to me. The standard difference is 69 APEX96.

APEX96 to ISO (in whichever system) is 3.125*(2(APEX96/96))
Thanks.   Despite all the conversations about this recently ( http://chdk.setepontos.com/index.php?topic=10341.0 ) its still comes as a bit of a shock when I see the difference in another context.  No wonder people have been somewhat upset over the years.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline lapser

  • *****
  • 1093
Re: 1.3 development proposal - exposure conversion functions
« Reply #19 on: 31 / August / 2013, 13:59:24 »
First of all, great job, as usual, Phil. I love the way you implemented it, and the seconds_to_tv96 function should do all I want in a much clearer way than the negative time input and scale factor I used. The docs that waterwingz wrote are perfect too Thanks!

I noticed that Phil uses a (short) argument for a function that I thought was defined to have an (int) argument. I didn't realize the compiler would implicitly convert in that case. It's nice to learn something new.

Code: [Select]
ISO 200 = SV96 576
ISO 200 real  = ISO329 market        <--- really ?
ISO 200 market = ISO122 real         <--- can this be true ?
SV96 576 real = 645 market            <-- here too
SV96 576 market = 507 real            <-- and here
The idea is that doubling the market ISO should double the real ISO. This translates to adding 96 to the real or market sv96. So the sv96 conversion is a constant offset:

sv96 market = sv96 real + offset.

In my cameras, the offset it 59, but Canon picks the offset for each camera depending on the properties of the sensor. I think they're trying to match the exposure of a old style film camera with various ISO film speeds.

sv96 addition is ISO multiplication, so:

ISO market = ISO real * 2^(offset/96).
ISO market = ISO real *1.53 -- for a sv96 offset of 59

So ISO 200 real = ISO 306 Market on my cameras. Your camera sv96 offset must be a little larger.

I think maybe the purpose for the sv96 "base" and "delta" propcases may be that higher ISO film (physical  film) speeds aren't exactly double the next lower film speed. ISO 3200 film isn't exactly twice as sensitive as ISO 1600 film. The constant sv96 offset for real and market holds true up to ISO 800 on my cameras, but above that it isn't the same, I've found.

I'm not sure how Phil handled this, but I'm happy with it however he did it. I just ignored it in my script, and used a constant offset. I only used market ISO for input and display, and all the exposure changes were s96 real.
***
I see phil and reyalp have answered this while I'm typing, and phil uses 69 for the conversion. Is this for all cameras?

[EDIT]
This is how I find the offset in my script:
Code: [Select]
sv=get_sv96()
svdiff=iso_to_sv96(get_iso_market())-sv  -- real to market difference
svmin=iso_to_sv96(s)-svdiff -- min sv ISO 100 market default
svmax=iso_to_sv96(z)-svdiff
« Last Edit: 31 / August / 2013, 14:14:23 by lapser »
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

 

Related Topics