Automatic Focus & Exposure Bracketing Script

Started by garry23, April 28, 2016, 12:12:25 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

garry23

Still photographers may be interested in my latest script that captures exposure and focus brackets, ie together.

I have added info here: http://photography.grayheron.net/2016/04/the-ultimate-bracketing-tool-but-only.html

And here is the script:

--[[
Landscape auto exposure & focus bracketing script
Release 0.5
This version has no error detection so the user must be aware of certain things:
* Check the correct DoF diffraction options are set in ML, eg diffraction aware is on
* Must use a lens that reports focus distance and DoF can be calculated
* Lens must be in AF mode
* Must be in manual mode
* Switch stabalisation off as you will not be hand holding ;-)
* Must be in LV mode
* Assumes lens is focused at nearest point to start, ie script moves to infinity
* Script takes last bracket with focus point at infinity
--]]

-- Declare a few variables for the script
a1 = 0
b1 = 0
a2 = 0
b2 = 0
fp = 0
inf = 100000
delay = 0
base_tv = 0
delay = 0
factor = 0
num_brackets = 0

function check_bookend()
if keymenu.submenu["Bookends?"].value == "yes"
then
base_tv = camera.shutter.ms
camera.shutter.ms = 1
camera.shoot(64, false)
camera.shutter.ms = base_tv
end
end

function take_image()
local i = 0
camera.shoot(64, false)
if factor ~= 0
then -- take exposure brackets
base_tv = camera.shutter.apex
for i = 1, num_brackets , 1
do
camera.shutter.apex = camera.shutter.apex - factor
camera.shoot(64, false)
end
camera.shutter.apex = base_tv
check_bookend()
end
end

function albs()
-- check not an EOSM
menu.close()
if camera.model_short == "EOSM"
then
display.notify_box("Sorry doesn't work with the EOSM", 3000)
else
-- Get DoF info, delay as requested & take first bracket
msleep(delay)
a2 = lens.dof_near
b2 = lens.dof_far
if factor ~= 0
then -- calculate number of brackets
num_brackets = (tonumber(keymenu.submenu["Shadow Ev"].value) - tonumber(keymenu.submenu["0Ev offset"].value)/10)/factor
num_brackets = math.floor(num_brackets)
if num_brackets <= 1 then num_brackets = 1 end
end
check_bookend()
if num_brackets ~= 0 then check_bookend() end
take_image()
-- take remaining brackets to infinity end
repeat
a1=a2
b1=b2
repeat
lens.focus(-1,1)
b2 = lens.dof_far
a2 = lens.dof_near
fp = lens.focus_distance
until a2 > b1 or fp >= inf
lens.focus(1,1)
take_image()
until fp >= inf
check_bookend()
end
end

keymenu = menu.new
{
    parent = "Shoot",
    name = "Auto Focus Bracketing",
    help = "Remember: LV, DoF & AF on + focus at nearest point",
depends_on = DEPENDS_ON.LIVEVIEW,
    submenu =
{
{
name = "Run Script",
help = "Does what it says after pressing SET",
select = function(this) task.create(albs) end,
},
{
name = "Delay",
help = "Delays script start by stated number of secs",
choices = {"2","5","0"},
update = function(this)
delay = tonumber(keymenu.submenu["Delay"].value)*1000
end,
},
{
name = "Bookends?",
help = "Places a dark frame at start and end of focus bracket set",
choices = {"no","yes"},
},
{
name = "Shadow Ev",
help = "As measured by shadow Ev from ML Spotmeter",
help2 = "value in integer positive (Ev) stops",
min = 1,
           max = 20,
value = 5,
},
{
name = "0Ev offset",
help = "Number stops (x10) Canon 0Ev is assumed down from highlight max",
help2 = "uses tenths of an Ev",
min = 10,
max = 60,
value = 35,
},
{
name = "Ev bracket delta per image",
help = "0 = no exposure bracketing",
help2 = "Bracketing limited to 1 or 2",
choices = {"0","1","2"},
update = function(this)
factor = tonumber(keymenu.submenu["Ev bracket delta per image"].value)
end
}
}
}

Audionut

I should probably try this before commentating.  Can you explain further what "Shadow Ev" and "0Ev offset" do?
To me, it reads as if they both do the same thing, that is, set some exposure point where the bracket stops.

Ottoga

EOS 7D.203, EFS 55-250mm, EF 75-300 III, Tamron 16-300 DiII VC PZD Macro, SpeedLite 580EX II.

Audionut

My suggestion.

--[[
Landscape auto exposure & focus bracketing script
Release 0.5
This version has no error detection so the user must be aware of certain things:
* Check the correct DoF diffraction options are set in ML, eg diffraction aware is on
* Must use a lens that reports focus distance and DoF can be calculated
* Lens must be in AF mode
* Must be in manual mode
* Switch stabalisation off as you will not be hand holding ;-)
* Must be in LV mode
* Assumes lens is focused at nearest point to start, ie script moves to infinity
[b]* Assumes highlights are ETTR'd to start[/b]
* Script takes last bracket with focus point at infinity
--]]


I can read the opening lines of the script and know where exposure and focus should start.


{
name = "Shadow EV",
help = "Shadow area as measured by ML spotmeter",
help2 = "Value in negative (full) EV stops",
min = -1,
                        max = -20,
value = -5,
},


ML spotmeter reads in negative units from saturation.  Since the base exposure should be ETTR'd, it seems more obvious that this shadow EV point is the negative EV as reported by the ML spotmeter from the shadow area of interest (in the ETTR'd image).

The maximum negative value of the ML spotmeter on my 6D is 13 EV.  I assume that being able to set a value of 20, means that the script will act as if the ML spotmeter read -20 EV?  And expose accordingly?



{
name = "Highlight 0 EV offset",
help = "Number stops between Canon 0 EV and highlight max",
help2 = "As measured by ML spotmeter. Uses tenths of an EV",
min = 10,
max = 60,
value = 35,
},


I can't see any other way to write this without assuming the user can point the camera at something, meter it a 0 EV, and read the ML spotmeter reading.



{
name = "Ev bracket delta per image",
help = "0 = no exposure bracketing",
help2 = "Bracketing limited to 1 or 2",
choices = {"0","1","2"},
update = function(this)
factor = tonumber(keymenu.submenu["Ev bracket delta per image"].value)
end
}
}
}


I assume this one sets the EV limit between exposures?

And I'm guessing that the shadow area selected with "Shadow EV" is (eventually) exposed at 0 EV on the Canon meter?

edit:  And something else.
* Image review must not be set to HOLD in Canon menu

garry23

@Ottoga/@Audionut

First of all many thanks for taking to time to provide feedback on my script, which obviously was written to accommodate my photography preferences  ;D

Although I personally always exposure bracket from an ETTR point, you don't need to, ie you can choose another exposure to account for the highlight capture end of your exposure bracket set.

As for capturing the shadow detail, I personally make use of the Raw ML spotmeter, which tells me how many stops that metered point is from the ETTR highlight point, ie from the (ETTR) 0Ev. Yes the spotmeter gives you this value as a negative, and the script asks you to input the modulus of the spotmeter reading. Yes you can change the menu to put this input into negative values if you wish, and change the math in the script to accommodate this. I may even do this myself  ;)

I decided to add in the 0Ev offset as a way of moving the final bracket around. You may not wish to place it at the Canon 0Ev point, so you choose.

I limited the bracket deltas to 1 or 2 stops, but you can easily tune that in the script to your needs.

As I say, I really welcome feedback like this as it helps simpletons like me.

I also like the idea of the ML Lua 'scripters' bootstraping off each others ideas: hint I would love to see others publish their humble attempts in Lua-space.

Once again: thanks @Ottoga/@Audionut

xorpi

AWESOME!!! DREAMS COME TRUE!!! <3 BIG LIKE!!!

Bring it to the next build of magic lantern instalation native :)  :) :) :) :)
Think Dynamic! #HDR #BW 📸

Photography & FineArt by photofrano 🎨   
www.fb.com/PHOTOFRANO & www.500px.com/PHOTOFRANO