Sunday, May 1, 2016

Revision 2

A short post today to simply publish the latest version of my auto focus and exposure script for Magic Lantern users.

This one is as automated as I can get it. As with previous versions, this one has little 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 stabilization off as you will not be hand holding ;-) 
  • Must be in LV mode
  • ETTR settings should be no dual-ISO, S/Ns to zero, highlights very low or zero 
  • ETTR mode, eg SET or SNAP, can be left as your default as the script will protect this
  • Image review must not be set to HOLD in Canon menu 
  • Assumes lens is focused at nearest point to start, ie script moves to infinity 
  • Script takes last brackets with focus point at infinity 
  • When exposure bracketing, set base exposure to capture shadows (the script will calculate the ETTR of the scene) 
  • If ETTR fails, then try adjusting line 58 to give your camera more time (or experiment with less)
As photography should be relaxing, I personally don't mind that this script takes time to run. So, as it's running, look around you and enjoy nature and the moment :-)

Finally, I haven't had a chance to test every scenario, but I'm content it works for me. Here are a couple of test images I took to 'prove things out'. The outdoor shoot was taken in our back garden and there was a little bit of a breeze, so you will see motion in the foliage.

I processed these two (24mm) images fully in Lightroom, using the LR 32-bit HDR technology to process each exposure set of brackets, adjusted one and synced to the others, then took this processed/synced exposure set on a round trip to Helicon Focus from within LR.

As usual I welcome feedback, especially if you are having problems with the script or would like to see some changes.






--[[
Landscape auto exposure & focus bracketing script
Release 0.7
This version has little 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
* ETTR settings should be no dual, S/Ns to zero, highlights very low or zero
* Image review must not be set to HOLD in Canon menu
* Assumes lens is focused at nearest point to start, ie script moves to infinity
* Script takes last bracket with focus point at infinity
* When exposure bracketing, set base exposure to capture shadows (the script will calculate the ETTR of the scene)
* If ETTR fails, then try adjusting line 58 to give your camera more time (or experiment with less)
* Final thought: photography should be relaxing, hence I personally don't mind that this script takes time to run. As it's
* running look around you and enjoy the moment :-)
--]]

-- 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
first_call = true
num_brackets = 0
ETTR_tv = 0
base_tv = 0

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

function take_brackets()
    if keymenu.submenu["Ev bracket delta per image"].value ~= "0"
    then
    if first_call
    then
-- Find the ETTR shutter value
    base_tv = camera.shutter.apex
    local m = menu.get("Auto ETTR","Trigger mode")
    menu.set("Auto ETTR","Trigger mode",0) -- set ETTR menu to get an ETTR exposure
    local check_tv = 0
    lv.start()
    repeat -- hang around until ETTR value has stabilised
    check_tv = camera.shutter.apex
    msleep (4000)  -- adjust this for your camera (this works on a 5D3). The time delay allows the ML ETTR to settle down
    until check_tv == camera.shutter.apex
    ETTR_tv = camera.shutter.apex
    menu.set("Auto ETTR","Trigger mode",m) -- reset to user ETTR menu setting
    num_brackets = (ETTR_tv - base_tv)/factor
    num_brackets = math.floor(math.abs(num_brackets))
    if num_brackets <= 1 then num_brackets = 1 end
    end
    camera.shutter.apex = ETTR_tv
    camera.shoot(64, false)
    for i = 1, num_brackets , 1
    do
    camera.shutter.apex = camera.shutter.apex - factor
    camera.shoot(64, false)
    end

    if camera.shutter.apex > base_tv
    then
    camera.shutter.apex = base_tv   
    camera.shoot(64, false)
    end
    else
    camera.shoot(64, false)
    end
    first_call = false
end

function albs()
-- check not an EOSM
first_call = true
menu.close()
if camera.model_short == "EOSM"
then
display.notify_box("Sorry doesn't work with the EOSM", 3000)
else
    base_tv = camera.shutter.apex  -- get exposure that is set for the shadows
    check_bookend()
--     Get DoF info, delay as requested & take first brackets
    msleep(delay)
    a2 = lens.dof_near
    b2 = lens.dof_far
    take_brackets()
-- take remaining focus 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_brackets()
    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 -- delay in ms
            end,
        },
        {
            name = "Bookends?",
            help = "Places a dark frame at start and end of focus bracket set",
            choices = {"no","yes"},
        },
       
        {
            name = "Ev bracket delta per image",
            help = "0 = no auto exposure bracketing",
            choices = {"0","1","2"}, -- change these values to your own choices
            update = function(this)
            factor = tonumber(keymenu.submenu["Ev bracket delta per image"].value)
            end
        }
    }
}

No comments:

Post a Comment