Skip to content

Instantly share code, notes, and snippets.

@pigeonhill

pigeonhill/DOFIS.lua

Last active Oct 29, 2020
Embed
What would you like to do?
Depth Of Field Info (Split lens version)
--[[
DOFIS
Depth of Field Info Script
NOTE: This script assumes you are running the Lua fix from the experimental area or have the Lua fix module in your build, ie Latest Lua fix Build (2019-03-20 09:28)
This script dynamically displays (in the ML top bar) the enhanced focus information.
If the display option is set to DoFs, then if you are focused less than H, DOFI will show the relative (R), either side of the point of focus,
or absolute (A) DoFs, relative to the sensor, plus show the blurs when focus is greater than H.
The script is macro aware and will switch DoF models if the magnification is greater than the one you set in the DOFIS menu. Macro DoF reporting only works in relative DoF mode.
DOFIS provides visual feedback when a user-set diffraction criterion is met, ie a diffraction limited point. One way to set this is to assume it is at. say, 3 sensor pixcels.
Green means below the limit, red above the limit.
The script visually shows the overlap status to aid focus bracketing: green means a positive overlap and red a focus gap between the current focus and the last image taken and...
yellow means the current focus is the same as the last image captured. The criterion used is the ML CoC value, with or without diffraction awareness.
If full auto focus bracketing is switched on and a registered AF lens is found, and focus is less than H, and diffraction is not too high, then DOFIS will automatically focus bracket just past the hyperfocal...
where you can decide to take an additional infinity shot, if required. But note, Canon focus feedback becomes coarser as you focus towards infinity, so focus control becomes harder.
You can use DOFIS exposure bracketing only in full mode and when focus bracketing is off. Note: ML AB is temporally switched off.
DOFIS exposure bracketing assumes you have ETTRed the scene as your base exposure and that you wish to exposure bracket for the shadows, based on the RAW spotmeter value...
you have given DOFIS and the Ev value, relative to the highlights, that you wish this be raised too.
If semi auto focus bracketing is switched on (dx or H), then pressing the trigger key will move the lens to the next focus position requested.
In semi mode you can use ML AB, but not DOFIS AB.
Note in semi H mode, DOFIS will move the lens close to H, ie just before or just after, following which you can manually fine tune.
You can switch off auto focus bracketing and only use DOFIS exposure bracketing.
DOFIS will also show an estimate of the number of brackets from where you are focused to the (overlap) hyperfocal.
Changing aperature or focal length will reset DOFI bracketing, as will exposing the ML menu, eg to access additional info.
You can choose betwen a (registered) zoom, asymmetric, split thin lens model or a simple thin lens model. DOFIS shows this as S or T.
DOFIS alerts you to diffraction aware being on by displaying a + rather than a - to the right of the S ot T alert.
The normal DOFIS feedback has the following format: {S or T}{- or +}{#n or =H or >H or INF}{A or R}{[near DoF][far DoF] or [near DoF][blurs] or [blurs]}
You need to set the ML CoC, as this will be the the defocus overlap criterion. If diffraction aware is on, overlap will be adjusted so the ML Coc is the total blur...
comprised of the defocus blur and the diffraction blur in quadrature. If the diffraction blur is greater than the ML CoC, DOFIS will alert you.
If registered in the script, and found, a lens will be automatically used in Auto mode. Also, in Auto mode, if the lens is not found, DOFIS defaults to a thin lens model, thus
I recommend the Auto setting always be on.
Finally, you can access other infomation in the DOFIS menu, eg the FoVs and magnification at your point of focus etc. Note, this info will change according to whether you are...
using a registered lens or a thin lens; for example, to fully account for focus breathing in the FoV, DOFIS needs to know the pupil magnification.
Release 1.785
October 2020
Garry George
photography.grayheron.net
--]]
require("config")
mylens = {}
--[[
Add your Lens Info here
DOFIS relies on Canon/ML distance reporting is 'acceptable' ;-)
Best to measure the lens Max Mag yourself or seek our actual manufactuer's data, ie rather than using advertising data
Also, measure pupil mag by taking focused images of the exit and entrance pupils, with a focused ruler in the plane of the pupil...
(for example see http://photography.grayheron.net/2020/09/dofis-start-of-major-update.html)
I recommend setting move to 0 on the EOSM or any camera where the lens movement is too slow, eg a macro lens. Use ML focus bracketing or just use manual DOFIS feedback when focus bracketing.
--]]
-- Lens #1
mylens[1] = {}
mylens[1][1] = "12-24mm" -- lens name
mylens[1][2] = 0.154 -- Max Mag at longest FL
mylens[1][3] = 280 -- Minimum Focus at longest FL
mylens[1][4] = 24 -- Longest FL
mylens[1][5] = -1 -- move direction (towards infinity)
mylens[1][6] = 6.4 -- Pupil mag at widest FL
mylens[1][7] = 4.2 -- Pupil mag at longest FL
mylens[1][8] = 12 -- Widest FL
mylens[1][9] = 0.085 -- Max Mag at widest FL
mylens[1][10] = 280 -- Minimum Focus at widest FL
--Lens #2
mylens[2] = {}
mylens[2][1] = "EF24-105mm f/4L IS USM"
mylens[2][2] = 0.227
mylens[2][3] = 450
mylens[2][4] = 105
mylens[2][5] = -1
mylens[2][6] = 4.08
mylens[2][7] = 1
mylens[2][8] = 24
mylens[2][9] = 0.071 -- Max Mag at widest FL
mylens[2][10] = 480 -- Minimum Focus at widest FL
--Lens #3
mylens[3] = {}
mylens[3][1] = "EF100mm f/2.8L Macro IS USM"
mylens[3][2] = 1.0
mylens[3][3] = 300
mylens[3][4] = 100
mylens[3][5] = 0
mylens[3][6] = 0.846
mylens[3][7] = 0.846
mylens[3][8] = 100
mylens[3][9] = 1.0 -- Max Mag at widest FL
mylens[3][10] = 300 -- Minimum Focus at widest FL
--Lens #4
mylens[4] = {}
mylens[4][1] = "EF-M11-22mm f/4-5.6 IS STM"
mylens[4][2] = 0.3
mylens[4][3] = 150
mylens[4][4] = 22
mylens[4][5] = 0
mylens[4][6] = 3.2
mylens[4][7] = 2.26
mylens[4][8] = 11
mylens[4][9] = 0.13 -- Max Mag at widest FL
mylens[4][10] = 150 -- Minimum Focus at widest FL
--Lens #5
mylens[5] = {}
mylens[5][1] = "TS-E24mm f/3.5L II"
mylens[5][2] = 0.34 -- Max Mag at longest FL
mylens[5][3] = 230 -- Minimum Focus at longest FL
mylens[5][4] = 24 -- Longest FL
mylens[5][5] = 0 -- move direction (towards infinity)
mylens[5][6] = 2.64 -- Pupil mag at widest FL
mylens[5][7] = 2.64 -- Pupil mag at longest FL
mylens[5][8] = 24 -- Widest FL
mylens[5][9] = 0.34 -- Max Mag at widest FL
mylens[5][10] = 230 -- Minimum Focus at widest FL
-- add additional lenses here and remove comment dashes. Make sure lens[n] number is contiguous with previous lenses
--Lens #n
--mylens[n] = {}
--mylens[n][1] =
--mylens[n][2] =
--mylens[n][3] =
--mylens[n][4] =
--mylens[n][5] =
--mylens[n][6] =
--mylens[n][7] =
--mylens[n][8] =
--mylens[n][9] =
--mylens[n][10] =
--********Change the following as required**********
button = KEY.RATE -- change as required *
button_t = "RATE" -- add a 4 letter reminder here *
wave = 0.550 -- 0.550 for visible band photography *
-- or 0.850 for IR (or another wavelength to suit *
-- your sensor conversion). In nm *
-- *
-- Explicity confirm your sensor data here *
sensor_h = 36 --*
sensor_v = 24 --*
sensor_p = 6.3 -- sensor photosite (um) *
p_factor = 3 -- 3 to 4, with 3 a mimimum for *
-- accounting for anti aliasing *
--**************************************************
menu.set("DOF Settings","DOF info in LiveView",0)
infinity = 655000 -- trap ML reported infinity
f = lens.focal_length
x = lens.focus_distance
a = camera.aperture.value
ML_blur = menu.get("DOF Settings","Circle of Confusion",0) -- this is the overlap blur you need to set in ML
defocus_blur = ML_blur
H = 0
ndof = 0
fdof = 0
infinity_blur = 0
diff_blur = 0
diff_blur_inf = 0
total_blur = 0
blurs = ""
num = 0
u = 0
last_f = f
last_x = 0
last_image_x = x
last_a = a
last_ndof = ndof
last_fdof = fdof
lens_0 = 0
lens_e = 0
card_count = dryos.shooting_card.file_number
CON = "ON"
COFF = "OFF"
image_taken = false
max_mag = 0
min_mag = 0
max_fl = 0
min_fl = 0
mfd = 0
mfd_l = 0
mfd_w = 0
temp = ""
more = {"LT","LE","FP","M@x","Focus","HF","Defocus","Diff","LN","#B","H-FoV","V-FoV","D-FoV","P_mag","Pano","Ratio","lp"}
choices1 = {"Blurs","R-DoFs","A-DoFs"}
choices2 = {"Auto","Thin"}
choices3 = {"OFF","Full","Semi(dx)","Semi(H)","X only"}
lens_t = 0
mag_u = 0
lens_model_ok = nil
diff = false
no_good = false
auto_bracket = false
direction = 0
working = false
new_u = 0
refresh = true
help_txt = ""
p_mag = 1 -- pupil mag at f
p = 0
exit_pupil = 0
ratio = 0
t_l = 0
t_w = 0
h = 0
current_fdof = 0
current_ndof = 0
mag_t = 0.5
lp_data = 0
lp = 0
function my_display(text,time,x_pos,y_pos)
text = string.rep("\n",y_pos)..string.rep(" ",x_pos)..text
display.notify_box(text,time*1000)
end
if (x==0 or a==0 or f==0) then
my_display("Can't use DOFIS",2,0,0)
return
end
function myround(num, dp) -- written this way to eliminate rounding errors with other approaches and because ML Lua doesn't have a string.format
if dp and dp>0 then
local adjusted = false
if num < 1 and num >= 0 then -- number positive and less than 1
num = num + 1 -- needed to protect 0s extraction
adjusted = true
elseif num < 0 and num > -1 then -- number negative and less than 1
num = num - 1 -- needed to protect 0s extraction
adjusted = true
end
local temp = math.floor(num) -- integer part
local temp2 = tostring(math.floor(num*10^dp)) -- shift dp and round
temp2 = temp2:sub(-dp) -- decimal part
if adjusted and num >= 0 then
temp = "0"
elseif adjusted and num < 0 then
temp ="-0"
end
return temp.."."..temp2
end
return tostring(math.floor(num))
end
function x2u(xin) -- convert from sensor to front principal focus distance
return xin-lens_0
end
function update()
f = lens.focal_length
a = camera.aperture.value
x = lens.focus_distance
last_x = x
last_f = f
last_a = a
ML_blur = menu.get("DOF Settings","Circle of Confusion",0)
if f ~= last_f or a ~= last_a or menu.visible then -- reset bracketing
image_taken = false
end
if DOFIS_Menu.submenu["Diffraction Aware"].value == CON then diff = true else diff = false end
if DOFIS_Menu.submenu["Lens Model"].value == "Auto" then -- check for a registered lens
lens_model_ok = false
lens_t = 0
p = 0
p_mag = 1
for i=1,#mylens do
local mag_f = 0
local X_f = 0
if lens.name == mylens[i][1] then
max_mag = mylens[i][2]
min_mag = mylens[i][9]
mfd_l = mylens[i][3]
mfd_w = mylens[i][10]
max_fl = mylens[i][4]
min_fl = mylens[i][8]
if max_fl ~= min_fl then -- this is a zoom lens, so estimate MFD, Max Mag and p_mag at f, ie assume linear change over zoom range
mag_f = min_mag + ((f-min_fl)*(max_mag-min_mag))/(max_fl-min_fl)
X_f = mfd_w + ((f-min_fl)*(mfd_l-mfd_w))/(max_fl-min_fl)
p_mag = mylens[i][6] + ((f-min_fl)*(mylens[i][7]-mylens[i][6]))/(max_fl-min_fl)
else -- it's a prime lens
mag_f = max_mag
X_f = mfd_l
p_mag = mylens[i][6]
end
lens_t = X_f - (f*(1+mag_f)*(1+mag_f))/mag_f
direction = mylens[i][5]
p = f*(1-1/p_mag)
lens_model_ok = true
break
end
end
elseif DOFIS_Menu.submenu["Lens Model"].value == "Thin" then
lens_model_ok = false
lens_t = 0
p = 0
p_mag = 1
else
lens_model_ok = nil -- shouldn't ever get here
end
do
if x > infinity then
mag_u = 0
else
local q = x - lens_t
mag_u = (q-2*f-math.sqrt(q*(q-4*f)))/(2*f) -- magnification
end
end
diff_blur = 2.44*wave*a*(1+mag_u/p_mag) -- at focus x
diff_blur_inf = 2.44*wave*a -- at infinity
defocus_blur = ML_blur -- zero diffraction case
if diff then -- calculate defocus blur
if diff_blur < ML_blur then
defocus_blur = math.sqrt(ML_blur*ML_blur - diff_blur*diff_blur)
no_good = false
else
--no_good = true -- diffraction too high
defocus_blur = 1
no_good = true
end
end
h = (1000*f*f)/(a*defocus_blur)
H = h + f -- as measured from the front principal, ie insensitive to pupil mag
do -- esitmate of diffraction impacted resolution FoM
local aa = 380/(wave*a*(1+mag_u/p_mag)) -- (lp/mm) MTF50 diffraction based resolution at aperture a
local bb = 1000/(p_factor*sensor_p) -- (lp/mm) sensor max resolution
local cc = 380/((wave*camera.aperture.min.value)) -- (lp/mm) MTF50 diffraction based resolution, wide open and at infinity
local dd = (1/aa)*(1/aa) + (1/bb)*(1/bb)
lp = math.sqrt(1/dd) -- lp/mm estimate
dd = math.sqrt(((1/cc)*(1/cc) + (1/bb)*(1/bb))/dd)
lp_data = 100*dd -- % lp/mm resolution reduction from infinity and wide open
end
lens_e = f*mag_u -- lens extension. Zero at infinity
u = x2u(x) -- focus distance from 'front principal'. Note: H, FoV and all relative DoF calculations are sensitive to entrance pupil's location
lens_0 = f + lens_e + lens_t -- estimate position of 'front principal' from the sensor plane
infinity_blur = defocus_blur*(H-f)/(u-f) -- defocus infinity blur
exit_pupil = myround((lens_0+p),0) -- exit pupil position or pano pivot point
-- estimate of (non-macro) absolute depths of field
ndof = u-((u-f)*(u-p))/(h+(u-f)) -- as measured from the front principal, but factoring in the pupil mag
if u < H then
fdof = u+((u-p)*(u-f))/(h-(u-f)) -- from the front principal
ratio = (u-ndof)/(fdof-u) -- relative near/far DoF ratio
else
fdof = infinity
ratio = 0
end
mag_t = DOFIS_Menu.submenu["Mag Model"].value/10
if mag_u > mag_t then -- use macro DoF estimates
ndof = (0.002*wave*((1+mag_u/p_mag)*a)*((1+mag_u/p_mag)*a))/(mag_u*mag_u)
fdof = u+ndof
ndof = u-ndof
end
-- estimate [:-)] of number of focus brackets to get to H
do
local u_stop = H/3
local uu = u
if uu < u_stop then
num = 2
while uu < u_stop
do
uu=(uu*(H-2*f))/(H-2*uu)
num = num + 1
end
elseif u > H then
num = 1
else
num = 2
end
end
total_blur = math.sqrt(infinity_blur*infinity_blur + diff_blur*diff_blur)
if DOFIS_Menu.submenu["Display Options"].value == "Blurs" then -- only show infinity blurs
blurs = "["..myround(infinity_blur,0).."/"..myround(diff_blur,0).."/"..myround(total_blur,0).."]"
else
local tempn, tempf = 0, 0
if x > infinity then -- no info here
blurs = ""
elseif u >= H then -- only show infinity blurs
if (h+f+lens_0) > 1000 then
temp = myround((h+f+lens_0)/1000,2).."m"
else
temp = myround((h+f+lens_0)/10,0).."cm"
end
blurs = "H:"..temp..":["..myround(infinity_blur,0).."/"..myround(diff_blur,0).."/"..myround(total_blur,0).."]"
else
if DOFIS_Menu.submenu["Display Options"].value == "R-DoFs" then
tempn = u-ndof
tempf = fdof-u
if mag_u > mag_t then
blurs = "["..myround(tempn,1).."mm]M["..myround(tempf,1).."mm]"
elseif tempf > 1000 then
blurs = "["..myround(tempn/1000,2).."m]R["..myround(tempf/1000,2).."m]"
elseif tempn < 100 then
blurs = "["..myround(tempn).."mm]R["..myround(tempf).."mm]"
else
blurs = "["..myround(tempn/10,0).."cm]R["..myround(tempf/10,0).."cm]"
end
else
tempn = ndof+lens_0
tempf = fdof+lens_0
if tempf > 1000 then
blurs = "["..myround(tempn/1000,2).."m]A["..myround(tempf/1000,2).."m]"
else
blurs = "["..myround(tempn/10,0).."cm]A["..myround(tempf/10,0).."cm]"
end
end
end
if no_good and (mag_u < mag_t) then blurs = "N 2 high" end
end
end
function my_shoot()
if DOFIS_Menu.submenu["Ev delta"].value == 0 then -- capture single image
camera.shoot()
else -- carry out exposure bracketing from an ETTR exposure
local current_shutter = camera.shutter.apex
local shutter = current_shutter
local start_value = DOFIS_Menu.submenu["Spotmeter Ev"].value
local ev_delta = DOFIS_Menu.submenu["Ev delta"].value
camera.shoot()
while start_value < DOFIS_Menu.submenu["Shadow Ev"].value
do
start_value = start_value + ev_delta
shutter = shutter - ev_delta
if shutter < -4 then -- switch to bulb mode
camera.bulb(2^(-shutter))
else
camera.shutter.apex = shutter
camera.shoot()
end
end
camera.shutter.apex = current_shutter
end
end
function check_auto_bracket()
working = true
auto_bracket = false
local xx = lens.focus_distance
local uu = x2u(xx)
local start_xx = xx
local focus_error = false
local exit_now = false
local diff_ok = true
local state = menu.get("Shoot","Advanced Bracket","") -- current ML AB state
if diff then -- calculate defocus blur
if diff_blur < ML_blur then
local defocus_blur = math.sqrt(ML_blur*ML_blur - diff_blur_inf*diff_blur_inf) -- use diffraction value at infinity, ie mag = 0
no_good = false
else
no_good = true -- diffraction too high
diff_ok = false
end
end
if lens_model_ok and lens.af and direction ~= 0 and diff_ok then -- carry out focus bracketing
local h = (1000*f*f)/(a*defocus_blur)
local H = h + f -- H as measured from the front principal
if DOFIS_Menu.submenu["Auto Bracketing"].value == "Full" and uu < H then
menu.set("Shoot","Advanced Bracket",0) -- Can't use this mode with advanced ML backeting
current_fdof = uu+((uu-p)*(uu-f))/(h-(uu-f)) -- as impacted by the pupil mag
sleep(DOFIS_Menu.submenu["Auto delay"].value)
my_shoot()
repeat
while not exit_now
do
repeat msleep(10) until lv.running
lens.focus(direction,2) -- move with medium steps towards the next focus position
repeat msleep(10) until lv.running
xx = lens.focus_distance
uu = x2u(xx)
current_ndof = uu-((uu-f)*(uu-p))/(h+(uu-f)) -- as impacted by the pupil mag
if current_ndof > current_fdof then exit_now = true end
end
exit_now = false
while not exit_now
do
repeat msleep(10) until lv.running
lens.focus(-direction,1) -- move back in small steps to achieve a positive overlap
repeat msleep(10) until lv.running
xx = lens.focus_distance
uu = x2u(xx)
if xx <= start_xx then -- error
focus_error = true
exit_now = true
beep()
end
current_ndof = uu-((uu-f)*(uu-p))/(h+(uu-f)) -- as impacted by the pupil mag
if current_ndof <= current_fdof then exit_now = true end
end
exit_now = false
my_shoot()
current_fdof = uu+((uu-p)*(uu-f))/(h-(uu-f)) -- as impacted by the pupil mag
start_xx = xx
until (uu >= H/3) or focus_error
repeat msleep(10) until lv.running
while lens.focus_distance < infinity do lens.focus(direction,1) end -- do an infinity shot
lens.focus(-direction,1)
my_shoot()
card_count = dryos.shooting_card.file_number
elseif DOFIS_Menu.submenu["Auto Bracketing"].value == "Semi(H)" then -- use semi auto bracketing
while x2u(lens.focus_distance) < H do lens.focus(direction,2) end
while x2u(lens.focus_distance) > H do lens.focus(-direction,1) end
lens.focus(direction,1)
elseif DOFIS_Menu.submenu["Auto Bracketing"].value == "Semi(dx)" then -- use semi auto bracketing
uu = x2u(xx)
if uu >= H then
current_fdof = infinity
else
current_fdof = uu+((uu-p)*(uu-f))/(h-(uu-f)) -- as impacted by the pupil mag
end
exit_now = false
if uu < H and current_fdof < infinity then
while not exit_now
do
repeat msleep(10) until lv.running
lens.focus(direction,2) -- move with medium steps towards the next focus position
repeat msleep(10) until lv.running
xx = lens.focus_distance
uu = x2u(xx)
current_ndof = uu-((uu-f)*(uu-p))/(h+(uu-f)) -- as impacted by the pupil mag
if current_ndof > current_fdof or xx >= infinity then exit_now = true end
end
exit_now = false
while not exit_now
do
repeat msleep(10) until lv.running
lens.focus(-direction,1) -- move back in small steps to achieve a positive overlap
repeat msleep(10) until lv.running
xx = lens.focus_distance
uu = x2u(xx)
current_ndof = uu-((uu-f)*(uu-p))/(h+(uu-f)) -- as impacted by the pupil mag
if xx <= start_xx then
exit_now = true
end
if current_ndof <= current_fdof then exit_now = true end
end
end
elseif DOFIS_Menu.submenu["Auto Bracketing"].value == "X only" then -- check and carry out exposure bracketing
menu.set("Shoot","Advanced Bracket",0) -- Can't use this mode with advanced ML backeting
sleep(DOFIS_Menu.submenu["Auto delay"].value)
my_shoot()
end
end
working = false
refresh = true
menu.set("Shoot","Advanced Bracket",state) -- switch ML AB back to the original state
end
function check_stuff()
if DOFIS_Menu.submenu["On/Off"].value == COFF then return true end
if auto_bracket then check_auto_bracket() end
if card_count ~= dryos.shooting_card.file_number and DOFIS_Menu.submenu["Focus Bracketing"].value == CON then
last_image_x = x
last_ndof = ndof
last_fdof = fdof
card_count = dryos.shooting_card.file_number
image_taken = true
end
if (last_f ~= lens.focal_length or last_a ~= camera.aperture.value or last_x ~= lens.focus_distance or menu.visible) or refresh then
if not working then
refresh = false
update()
end
end
return true
end
function check_keys(kk)
if kk == button and (not working) and DOFIS_Menu.submenu["Auto Bracketing"].value ~= COFF then
auto_bracket = true
return false
else
working = false
auto_bracket = false
return true
end
end
DOFIS_Menu = menu.new
{
parent = "Focus",
name = "DOFIS",
help = "Helps with infinity focusing & focus bracketing",
help2 = "Shows DoFs (abs or rel) + defocus, diffraction & total inf blurs",
depends_on = DEPENDS_ON.LIVEVIEW,
submenu =
{
{name = "On/Off",
choices = {CON,COFF},
},
{name = "Display Options",
choices = choices1,
help = "Relative DoFs or Blurs in DOFI window",
},
{name = "Focus Bracketing",
choices = {CON,COFF},
help = "Switches the focus bracketing feedback on or off",
help2 = "Useful when manual focus bracketing",
},
{name = "Auto Bracketing",
choices = choices3,
help = "Select auto focus bracketing option",
help2 = "Full = move (n(x to dx) to H) + shoot, Semi = move (x to dx or x to H)",
rinfo = function(this)
if this.value == "OFF" then
return ""
else
if menu.get("Shoot","Advanced Bracket",0) ~= 0 and this.value == "Full" then
this.help2 = "DOFIS will switch of ML AB"
return "AB On!"
elseif this.value == "Full" and lens.focal_length > 50 then
this.help2 = "Number of focus brackets"
return "#"..myround(num)
else
this.help2 = "Full = x to H, Semi = x to ?"
return button_t
end
end
end,
},
{name = "Diffraction Aware",
choices = {CON,COFF},
update = function(this)
if this.value == "ON" then
diff = true
else
diff = false
end
end,
help = "Switches diffraction on/off for DoFs",
},
{name = "Diff Feedback",
choices = {CON,COFF},
help = "Switches diffraction feedback on/off",
},
{name = "Spotmeter Ev",
min = -15,
max = -4,
unit = UNIT.DEC,
rinfo = function(this) return "Ev" end,
help = "Assumes an ETTR exposure",
help2 = "Value is shadows ML Raw Spotmeter Ev reading",
},
{name = "Ev delta",
min = 0,
max = 4,
unit = UNIT.DEC,
rinfo = function(this)
if this.value == 0 then
return "Off"
else
return "Ev"
end
end,
help = "Ev step for exposure bracketing",
help2 = "Use 4 for zero noise bracketing",
},
{name = "Shadow Ev",
min = -6,
max = -2,
unit = UNIT.DEC,
rinfo = function(this) return "Ev" end,
help = "Final Ev zone for spotmetered shadows, from highlights",
help2 = "Zone System zones III to VII = -6Ev to -2Ev",
},
{name = "Auto delay",
min = 0,
max = 2,
unit = UNIT.DEC,
help = "In seconds",
},
{name = "Lens Model",
choices = choices2,
help = "Switch between lens models",
rinfo = function(this)
if DOFIS_Menu.submenu["Lens Model"].value == "Auto" then
if lens_model_ok then
return "OK"
else
return "Not OK"
end
end
return ""
end,
},
{name = "Mag Model",
min = 5,
max = 10,
unit = UNIT.DEC,
value = 5,
rinfo = function(this)
mag_t = this.value/10
return myround(mag_t,1)
end,
help = "Mag to transition to macro model DoF",
help2 = "Mag shown on right",
},
{
name = "Additional Info",
choices = more,
rinfo = function(this)
help_txt = ""
if this.value == "LT" then
temp = myround(lens_t,0).."mm"
help_txt = "Lens thickness. Note: can be + or -"
elseif this.value == "LE" then
temp = myround(lens_e,2).."mm"
help_txt = "Focus lens extension. Note: zero at infinity"
elseif this.value == "FP" then
temp = myround(lens_0,0).."mm"
help_txt = "Front principal position relative to sensor"
elseif this.value == "M@x" then
temp = myround(mag_u,3)
help_txt = "Magnification at the current focus"
elseif this.value == "LN" then
temp = "LN: "..lens.name
my_display(temp,1,5,10)
temp = ""
help_txt = "Lens name for registering lens in DOFIS"
elseif this.value == "Focus" then
if x > infinity then
temp = "oo"
elseif x < 1000 then
temp = myround(x/10,0).."cm"
else
temp = myround(x/1000,2).."m"
end
help_txt = "From Canon: let's hope it's good enough ;-)"
elseif this.value == "Defocus" then
temp = myround(defocus_blur,0).."um"
help_txt = "Defocus blur, in microns"
elseif this.value == "Diff" then
temp = myround(diff_blur,0).."um"
help_txt = "Focus sensitive diffraction, in microns"
elseif this.value == "HF" then
if (h+f+lens_0) > 1000 then
temp = myround((h+f+lens_0)/1000,2).."m"
else
temp = myround((h+f+lens_0)/10,0).."cm"
end
help_txt = "Hyperfocal from the sensor plane"
elseif this.value == "#B" then
temp = "#"..myround(num)
help_txt = "Number of focus bracket to reach the hyperfocal"
elseif this.value == "H-FoV" then
temp = myround(114.591*math.atan(sensor_h/(2*f*(1+mag_u/p_mag))),1)
help_txt = "Horizontal/landscape FoV in degrees"
elseif this.value == "V-FoV" then
temp = myround(114.591*math.atan(sensor_v/(2*f*(1+mag_u/p_mag))),1)
help_txt = "Vertical/portrait FoV in degrees"
elseif this.value == "D-FoV" then
temp = math.sqrt(sensor_h*sensor_h + sensor_v*sensor_v)
temp = myround(114.591*math.atan(temp/(2*f*(1+mag_u/p_mag))),1)
help_txt = "Diagonal FoV in degrees"
elseif this.value == "P_mag" then
temp = myround(p_mag,1)
help_txt = "Pupillary magnification"
elseif this.value == "Pano" then
temp = exit_pupil.."mm"
help_txt = "Pano nodal postion from sensor"
elseif this.value == "Ratio" then
temp = myround(ratio,2)
help_txt = "Estimate of DoF ratio (near/far)"
elseif this.value == "lp" then
temp = myround(lp,0)
help_txt = "Diffraction impacted resolution in lp/mm"
end
return temp
end,
update = function(this)
this.help2 = help_txt
end,
help = "Toggle through additional info",
help2 = ""
}
}
}
lv.info
{
name = "DoF Info",
value = "",
priority = 100,
update = function(this)
this.background = COLOR.TRANSPARENT_BLACK
this.foreground = COLOR.WHITE
if DOFIS_Menu.submenu["On/Off"].value == COFF then
this.value = ""
else
this.value = blurs
end
end
}
lv.info
{
name = "more info",
priority = 100,
value = "",
update = function(this)
if DOFIS_Menu.submenu["On/Off"].value == CON then
this.background = COLOR.TRANSPARENT_BLACK
this.foreground = COLOR.WHITE
if DOFIS_Menu.submenu["Focus Bracketing"].value == CON then
if image_taken then
if (lens.focus_distance == last_image_x) then
this.background = COLOR.YELLOW
this.foreground = COLOR.BLACK
elseif (ndof > last_fdof) or (fdof < last_ndof) then
this.background = COLOR.RED
this.foreground = COLOR.WHITE
else
this.background = COLOR.GREEN1
this.foreground = COLOR.BLACK
end
end
end
if lens_model_ok == nil then
this.value = "??"
elseif lens_model_ok then
if diff then this.value = "S+" else this.value = "S-" end
else
if diff then this.value = "T+" else this.value = "T-" end
end
if x > infinity then
this.value = this.value.."oo"
elseif mag_u > mag_t then
this.value = this.value.."m"..myround(mag_u,2)
elseif (defocus_blur-infinity_blur) <= defocus_blur/10 and u > H then
this.value = this.value.."=H"
elseif u > H then
this.value = this.value..">H"
else
this.value = this.value.."#"..myround(num,0)
end
else
this.value = ""
end
end
}
lv.info
{
name = "Diff info",
priority = 100,
value = "",
update = function(this)
if DOFIS_Menu.submenu["On/Off"].value == CON and DOFIS_Menu.submenu["Diff Feedback"].value == CON then
this.background = COLOR.GREEN1
this.foreground = COLOR.BLACK
if (wave*a*(1+mag_u/p_mag))/0.38 > p_factor*sensor_p then
this.background = COLOR.RED
this.foreground = COLOR.YELLOW
end
this.value = myround(lp_data,0).."%"
else
this.value = ""
end
end
}
event.shoot_task = check_stuff
event.keypress = check_keys
config.create_from_menu(DOFIS_Menu) -- keep a track of the script's menu state at camera close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.