--[[@title Basic Landscape Bracketing'Perfect' focus brackets from near to blur defined 'infinity': overlap defined at a fraction of camera's CoCPlus option of two additional exposure brackets at each focus step, at 1Ev, 2Ev or 3Ev using -/+ or -/-- or +/++ logicUse Bookends to help differentiate bracket set in postMore info at https://chdk.wikia.com/wiki/Landscape_Focus_Bracketing_:_perfect_near_to_far_focus_bracketsCamera should be in manual focus mode and M modeRev 1.0April 2019Tested on a G7X(c) Garry George@chdk_version 1.5# overlap = 0 "Overlap at" {CoC 2CoC/3 CoC/2 diff}# delta = 0 "Exposure bracket delta?" {None 1Ev 2Ev 3Ev 800 1600 ZN}# logic = 0 "Exposure bracket logic?" {0/-/+ 0/-/-- 0/+/++}# delay = 3 "Script Delay (s)" [0 5]# bookends = 1 "Bookends?" {No Yes}# quality = 1 "Infinity focus quality?" {CoC/2 CoC/3 CoC/4}--]]capmode = require("capmode")if (capmode.get_name() ~= "M") then print("Switch to M mode") return -- exit scriptendif get_focus_mode() ~= 1 then print("Switch to MF mode") return -- exit scriptendif (get_focus() == -1) then print("@ Infinity") return -- exit scriptendpress("shoot_half") -- get current set camera valuest = get_tick_count()repeat sleep(50) if get_tick_count() - t > 5000 then print("Unknown Error") release("shoot_half") return -- exit script enduntil (get_shooting() == true)release("shoot_half") s = get_tv96() av = get_av96() set_tv96_direct(s) set_av96_direct(av) dof = get_dofinfo() x = dof.focus base_h = dof.hyp_dist -- that is without diffraction accounted for fl = dof.focal_length/100x_start = xlast_x = xtemp = 0temp1 = 0temp2 = 0ecnt = get_exp_count()function myshoot() -- so I can change shooting strategies ;-) press("shoot_half") repeat sleep(50) until (get_shooting() == true) local prevcnt=hook_shoot.count() press'shoot_full_only' repeat sleep(10) until prevcnt ~= hook_shoot.count() release'shoot_full_only' release("shoot_half")endfunction bookend() set_tv96_direct(960) set_av96_direct(640) ecnt = get_exp_count() myshoot() set_tv96_direct(s) set_av96_direct(av) repeat sleep(100) until (get_exp_count() ~= ecnt)endfunction refocus(xx) set_focus(xx) sleep(500) -- may need adjusting for some cams?endfunction X_bracket() set_tv96_direct(s) if delta == 0 then myshoot() elseif delta < 4 and logic == 0 then myshoot() set_tv96_direct(s-96*delta) myshoot() set_tv96_direct(s+96*delta) myshoot() elseif delta < 4 and logic == 1 then myshoot() set_tv96_direct(s+96*delta) myshoot() set_tv96_direct(s+2*96*delta) myshoot() elseif delta < 4 and logic == 2 then myshoot() set_tv96_direct(s-96*delta) myshoot() set_tv96_direct(s-2*96*delta) myshoot() elseif delta == 4 then local iso = get_sv96() set_sv96(sv96_market_to_real(iso_to_sv96(100))) myshoot() set_sv96(sv96_market_to_real(iso_to_sv96(800))) myshoot() set_sv96(iso) elseif delta == 5 then local iso = get_sv96() set_sv96(sv96_market_to_real(iso_to_sv96(100))) myshoot() set_sv96(sv96_market_to_real(iso_to_sv96(1600))) myshoot() set_sv96(iso) elseif delta == 6 then myshoot() set_tv96_direct(s-96*4) myshoot() end set_tv96_direct(s)endh = base_h -- no overlap case: brackets 'touch' at CHDK CoCif overlap == 1 then -- adjust h to achieve the requested overlap, ie 'touching' at 2*CoC/3 or CoC/2 or at the diffraction aware defocus blur h = (h*3)/2elseif overlap == 2 then h = 2*helseif overlap == 3 then -- use diffraction aware overlap: Assume CHDK CoC is total blur, formed in quadrature from defocus and diffraction blurs temp1 = 1000*dof.coc -- total blur set up for imath temp2 = (1342*dof.aperture)/1000 -- set up for imath. From diff_blur = 2.44*0.55*N (um) if temp1 > temp2 then -- can use diffraction aware overlap temp = imath.sqrt(imath.mul(temp1,temp1) - imath.mul(temp2,temp2)) -- diffraction aware defocus blur temp2 = imath.div(temp1,temp) if temp2 > 3000 then h = 3*h else h = (h*temp2)/1000 end else -- diff blur > total blur h = 3*h endendif (x > base_h or x == -1) then print("@/beyond H") if bookends == 1 then bookend() else sleep(delay*1000) end X_bracket() if bookends == 1 then bookend() end return -- exit scriptendif bookends == 1 then bookend() else sleep(delay*1000) endwhile (x < h/3) do -- capture focus brackets up to h/3 refocus(x) -- move to x X_bracket() dof = get_dofinfo() x = dof.focus -- register actual x moved by cam last_x = x x = (x*(h*10 - 2*fl))/(h*10 - 2*x*10) -- position of next focus bracket if x <= last_x or x <= 0 then print("Unknown Error") refocus(x_start) return end endrefocus(h/3) -- take shot at h/3X_bracket()temp2 = h*(quality+2)refocus(h) -- take shot at hX_bracket()if temp2 > h then -- take additional infinity focus shot refocus(temp2) X_bracket() endif bookends == 1 then bookend() endrefocus(x_start)
@reyalp More hours just trying to get to the bottom of 'my mystery', ie why my bookend function works at the end of the script, but not the beginning.As I said above, I can get it running ok, ie bookend taken, if I inject a 'random' sleep call: but I don't like this approach.
repeat sleep(10) until not get_shooting()
function myshoot() -- so I can change shooting strategies ;-) press("shoot_half") repeat sleep(50) until (get_shooting()) local prevcnt=hook_shoot.count() press'shoot_full_only' repeat sleep(10) until prevcnt ~= hook_shoot.count() release'shoot_full_only' release("shoot_half") repeat sleep(50) until (not get_shooting())end
--[[@title Basic Landscape Bracketing'Perfect' focus brackets from near to blur defined 'infinity': overlap defined at a fraction of camera's CoCPlus option of two additional exposure brackets at each focus step, at 1Ev, 2Ev or 3Ev using -/+ or -/-- or +/++ logicUse Bookends to help differentiate bracket set in postMore info at https://chdk.wikia.com/wiki/Landscape_Focus_Bracketing_:_perfect_near_to_far_focus_bracketsCamera should be in manual focus mode and M modeRev 1.0April 2019Tested on a G7X(c) Garry George@chdk_version 1.5# overlap = 0 "Overlap at" {CoC 2CoC/3 CoC/2 diff}# delta = 0 "Exposure bracket delta?" {None 1Ev 2Ev 3Ev 800 1600 ZN}# logic = 0 "Exposure bracket logic?" {0/-/+ 0/-/-- 0/+/++}# delay = 3 "Script Delay (s)" [0 5]# bookends = 1 "Bookends?" {No Yes}# quality = 1 "Infinity focus quality?" {CoC/2 CoC/3 CoC/4}--]]capmode = require("capmode")if (capmode.get_name() ~= "M") then print("Switch to M mode") return -- exit scriptendif get_focus_mode() ~= 1 then print("Switch to MF mode") return -- exit scriptendif (get_focus() == -1) then print("@ Infinity") return -- exit scriptendpress("shoot_half") -- get current set camera valuest = get_tick_count()repeat sleep(50) if get_tick_count() - t > 5000 then print("Unknown Error") release("shoot_half") return -- exit script enduntil (get_shooting())release("shoot_half")repeat sleep(50) until (not get_shooting()) s = get_tv96() av = get_av96() set_tv96_direct(s) set_av96_direct(av) dof = get_dofinfo() x = dof.focus base_h = dof.hyp_dist -- that is without diffraction accounted for fl = dof.focal_length/100x_start = xlast_x = xtemp = 0temp1 = 0temp2 = 0ecnt = get_exp_count()function myshoot() -- so I can change shooting strategies ;-) press("shoot_half") repeat sleep(50) until (get_shooting()) local prevcnt=hook_shoot.count() press'shoot_full_only' repeat sleep(10) until prevcnt ~= hook_shoot.count() release'shoot_full_only' release("shoot_half") repeat sleep(50) until (not get_shooting())endfunction bookend() set_tv96_direct(960) set_av96_direct(640) ecnt = get_exp_count() myshoot() set_tv96_direct(s) set_av96_direct(av) repeat sleep(100) until (get_exp_count() ~= ecnt)endfunction refocus(xx) set_focus(xx) sleep(500) -- may need adjusting for some cams?endfunction X_bracket() set_tv96_direct(s) if delta == 0 then myshoot() elseif delta < 4 and logic == 0 then myshoot() set_tv96_direct(s-96*delta) myshoot() set_tv96_direct(s+96*delta) myshoot() elseif delta < 4 and logic == 1 then myshoot() set_tv96_direct(s+96*delta) myshoot() set_tv96_direct(s+2*96*delta) myshoot() elseif delta < 4 and logic == 2 then myshoot() set_tv96_direct(s-96*delta) myshoot() set_tv96_direct(s-2*96*delta) myshoot() elseif delta == 4 then local iso = get_sv96() set_sv96(sv96_market_to_real(iso_to_sv96(100))) myshoot() set_sv96(sv96_market_to_real(iso_to_sv96(800))) myshoot() set_sv96(iso) elseif delta == 5 then local iso = get_sv96() set_sv96(sv96_market_to_real(iso_to_sv96(100))) myshoot() set_sv96(sv96_market_to_real(iso_to_sv96(1600))) myshoot() set_sv96(iso) elseif delta == 6 then myshoot() set_tv96_direct(s-96*4) myshoot() end set_tv96_direct(s)endh = base_h -- no overlap case: brackets 'touch' at CHDK CoCif overlap == 1 then -- adjust h to achieve the requested overlap, ie 'touching' at 2*CoC/3 or CoC/2 or at the diffraction aware defocus blur h = (h*3)/2elseif overlap == 2 then h = 2*helseif overlap == 3 then -- use diffraction aware overlap: Assume CHDK CoC is total blur, formed in quadrature from defocus and diffraction blurs temp1 = 1000*dof.coc -- total blur set up for imath temp2 = (1342*dof.aperture)/1000 -- set up for imath. From diff_blur = 2.44*0.55*N (um) if temp1 > temp2 then -- can use diffraction aware overlap temp = imath.sqrt(imath.mul(temp1,temp1) - imath.mul(temp2,temp2)) -- diffraction aware defocus blur temp2 = imath.div(temp1,temp) if temp2 > 3000 then h = 3*h else h = (h*temp2)/1000 end else -- diff blur > total blur h = 3*h endendif (x > base_h or x == -1) then print("@/beyond H") if bookends == 1 then bookend() else sleep(delay*1000) end X_bracket() if bookends == 1 then bookend() end return -- exit scriptendif bookends == 1 then bookend() else sleep(delay*1000) endwhile (x < h/3) do -- capture focus brackets up to h/3 refocus(x) -- move to x X_bracket() dof = get_dofinfo() x = dof.focus -- register actual x moved by cam last_x = x x = (x*(h*10 - 2*fl))/(h*10 - 2*x*10) -- position of next focus bracket if x <= last_x or x <= 0 then print("Unknown Error") refocus(x_start) return end endrefocus(h/3) -- take shot at h/3X_bracket()temp2 = h*(quality+2)refocus(h) -- take shot at hX_bracket()if temp2 > h then -- take additional infinity focus shot refocus(temp2) X_bracket() endif bookends == 1 then bookend() endrefocus(x_start)
BTW I'm also using your shooting suggestion, but I'm not sure it is much quicker than me just calling shoot()?
function myshoot() local prevcnt=hook_shoot.count() local rawprevcnt=hook_raw.count() press'shoot_full_only' repeat sleep(10) until prevcnt ~= hook_shoot.count() release'shoot_full_only' repeat sleep(10) until rawprevcnt ~= hook_raw.count()end
Does that mean your suggested change to myshoot, that does not involve a half press, needs to use a half press and release in the main section?
As you say, with my repeated refocusing, I don’t see how I can use a single press release half shoot.
Started by SkyWalker9 Script Writing
Started by SkyWalker9 « 1 2 » Completed and Working Scripts
Started by kidtree Completed and Working Scripts
Started by genosmm General Help and Assistance on using CHDK stable releases
Started by pigeonhill « 1 2 3 » Creative Uses of CHDK