Add function get_luminance() in LUA scripting - page 2 - Feature Requests - CHDK Forum  

Add function get_luminance() in LUA scripting

  • 18 Replies
  • 4174 Views
Re: Add function get_luminance() in LUA scripting
« Reply #10 on: 15 / April / 2012, 08:59:14 »
Advertisements
Ok, scripts runs without error.
However the resulting values are not good.
I use as reference the OSD misc values.
Those say
Bv: 3.60
B: 47.8

Mine say
Bv: 3.53 [CORRECT]
B: 272 [WRONG]
Please post the complete script you actually used to get these values.   

For example,   I think that
Code: [Select]
Bv = get_prop(34)
luminance_x10 = bit_shl(1, Bv/96) * 34
means that your B value of 272 is actually 27.2 (which is much closer to the "right" answer give in Kerr's table 5)

It would also be interesting to see how the two calculations track over a range of values from dark to light but I'd need to see how you coded this to figure it out.

Update :  Lua function get_bv() returns the value in PROPCASE_BV, which in your case is propcase(34).  So that change from reyalp's line of code is okay.
« Last Edit: 15 / April / 2012, 09:11:04 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

nosebleed

Re: Add function get_luminance() in LUA scripting
« Reply #11 on: 15 / April / 2012, 10:15:53 »
Yes it is 27.2. But still far from OSD misc values..
Just took a picture in full sunlight.
OSD misc values:
Bv: 12.10
B: 16361

My values
Bv: 11.59
B: 13926

Here is the code..
Code: [Select]
function get_bv()
press("shoot_half")
repeat sleep(100) until get_shooting() == true
Bv = get_prop(34)
printf("Bv = %d.%02d", Bv/100, math.abs(Bv) % 100)
luminance = bitshl(1, Bv/96) * 34
printf("Lum = %d.%02d", luminance/10, luminance%10)
release("shoot_half")
repeat sleep(100) until get_shooting() == false
end
« Last Edit: 15 / April / 2012, 10:26:06 by nosebleed »

Re: Add function get_luminance() in LUA scripting
« Reply #12 on: 15 / April / 2012, 11:35:42 »
Yes it is 27.2. But still far from OSD misc values..
Yes - they are different but bear in mind,  as reyalp pointed out above,  the luminance value reported on the OSD is based on a questionable formula - it might not be accurate.

Quote
Just took a picture in full sunlight.
OSD misc values:
Bv: 12.10
B: 16361

My values
Bv: 11.59
B: 13926
Good -  the results of either calculation track nicely from low to high brightness scenes.


I actually need luminance so I can control the shutter speed dynamically while the camera works.
Per my comment above,  it seems like either calculation is close enough to be usable in this application - its all a question of how you translate luminance to desired shutter speed.

Ported :   A1200    SD940   G10    Powershot N    G16

*

nosebleed

Re: Add function get_luminance() in LUA scripting
« Reply #13 on: 15 / April / 2012, 11:58:23 »
Per my comment above,  it seems like either calculation is close enough to be usable in this application - its all a question of how you translate luminance to desired shutter speed.
Yes, that's what I'm thinking now... But wait a second.
When I point the camera to full dark it has a slow shutter speed.. Which means it is already knowing that there is no light so it takes long so it can gather some light. The reverse is happening too. When I point it to full sun it takes the photo instantly. All this automatically..
So do I really need to have control over the shutter speed?
I have the same question for ISO too...
« Last Edit: 15 / April / 2012, 12:00:26 by nosebleed »


Re: Add function get_luminance() in LUA scripting
« Reply #14 on: 15 / April / 2012, 12:27:28 »
So do I really need to have control over the shutter speed?
I have the same question for ISO too...
You typically want to control shutter speed so that you get the result you want - fast shutter speeds to capture movement - slow shutter speeds to allow more light into the camera so that it can work at larger aperatures or lower ISO values  ( less noise ).  The camera does not know what sort of picture you are trying to take.

However,  P&S cameras can use "scene" setting to tell the camera what you are trying to do. This gives the same effect as controlling the camera manually and is generally easier for amateur photographers to understand.




Ported :   A1200    SD940   G10    Powershot N    G16

*

nosebleed

Re: Add function get_luminance() in LUA scripting
« Reply #15 on: 15 / April / 2012, 12:35:44 »
It's about high altitude ballooning pictures.
So the pictures will be like in full sunlight and the idol would be earth curvature and earth horizon.
Picture will be taken while camera is in crazy movements :)

PS, I have a facebook fun page for the mission. www.facebook.com/slaros.project
..and I would love to hear some expert advices for taking very nice shots during the flight :)
« Last Edit: 15 / April / 2012, 12:37:33 by nosebleed »

Re: Add function get_luminance() in LUA scripting
« Reply #16 on: 15 / April / 2012, 13:29:50 »
Lots of good stuff on this forum about CHDK on balloons.  Just search on "balloon".

Here's a couple :

http://chdk.setepontos.com/index.php?topic=2376.msg47097#msg47097
http://chdk.setepontos.com/index.php?topic=4541.msg44420#msg44420


and there is this :

http://eoss.org/hardware/canon_a570is.htm

and of coarse this :

https://github.com/jgrahamc/gaga/blob/master/gaga-1/camera/gaga-1.lua

Finally,  there is script for SDM that's been up there too if you want to try that (SDM may not be supported on your camera though) :

http://www.box.com/s/mnf6le1sj5t5ts2xnnus
« Last Edit: 15 / April / 2012, 16:54:13 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 12065
Re: Add function get_luminance() in LUA scripting
« Reply #17 on: 15 / April / 2012, 16:30:34 »
Hello reyalp and thanks for your long post..
I actually need luminance so I can control the shutter speed dynamically while the camera works.
For example, depending on the luminance my shutter should close fast or slow..
Then you should probably just do all your calculation in the cameras native APEX * 96 units.

Then you can just use the APEX equation (see the PDF I linked earlier) to calculate the correct epxosure directly in the cameras native units, using simple integer arithmetic.
Quote
luminance_x10 = bit_shl(1, get_bv96()/96) * 34, however it tells me "calling a global function with a nil value"
Oops, sorry about that, as waterwingz says, the shift function is bitshl.

Quote
Yes it is 27.2. But still far from OSD misc values..
What units are the OSD values in ? If I've understood correctly, the calculation is not correct for candelas/m^2, so it produces a value in some completely non-standard units.

Unless you have shutter speed, ISO etc in equivalent units, then you can't do any useful calculation with it. You could do a lookup table or something, but that would work just as well with bv96 values. Much simpler and more precise to use APEX values rather than converting.

Anyway, thanks for bringing this up, it looks like it exposed a bug.

I highly recommend you look at user fbonomi's posts about the stratospera project. The site is here http://www.stratospera.com/ (in Italian). If you search his posts, I think you can find some scripts and descriptions in English.
Don't forget what the H stands for.


*

nosebleed

Re: Add function get_luminance() in LUA scripting
« Reply #18 on: 16 / April / 2012, 15:21:11 »
Ok guys, that is lot of info. I need to study all those things before I make a new reply.
I'll try to get in contact with the Italian guy too...

Thank you all.

 

Related Topics