Skip to content

Instantly share code, notes, and snippets.

@pigeonhill
Last active June 7, 2017 12:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save pigeonhill/ab6b484bd8d9007671dca1cd669bfc76 to your computer and use it in GitHub Desktop.
--[[
This script simulates a super resolution stack for post processing...
by simulating sensor shifting by changing focus. Because of this, the script is 'limited' to taking...
sharp images between the HFD and infinity.
This script assumes you are on a tripod, ie not handholding as 'normal' in super resolution stacking (without a special sensor)
This version does NOT work with FRSP...at the moment :-)
Should be in LV
Canon review should be set to OFF
Usual caveat: script was written for my workflow and enjoyment, and 'only' tested on a 5D3
Version 0.2
*******************************************************************************************************
* *
* If you reference this script, please consider acknowledging me: http://photography.grayheron.net/ *
* *
*******************************************************************************************************
--]]
function my_shoot() -- to grab an image
camera.shoot(false)
end
function jiggle(around)
for i = 1, around do
key.press(KEY.HALFSHUTTER)
msleep(100)
key.press(KEY.UNPRESS_HALFSHUTTER)
end
end
function move() -- to HFD position irrespective of lens starting position
if lens.focus_distance ~= 0 and lens.af then -- lens is OK
if lens.dof_far ~= lens.dof_near then -- ok to move
if lens.focus_distance < lens.hyperfocal then
repeat
lens.focus(-1,2,false)
until lens.focus_distance >= lens.hyperfocal
repeat
lens.focus(1,1,false)
until lens.focus_distance <= lens.hyperfocal
repeat
lens.focus(-1,1,false)
until lens.focus_distance >= lens.hyperfocal
else
repeat
lens.focus(1,2,false)
until lens.focus_distance <= lens.hyperfocal
repeat
lens.focus(-1,1,false)
until lens.focus_distance >= lens.hyperfocal
end
else
beep (3, 200 , 500) -- warning message
display.notify_box("Check aperture", 3000)
end
else
beep (3, 200 , 500) -- warning message
display.notify_box("Check lens settings", 3000)
end
end
function check_lens_ready() -- just in case
if lens.focus_distance ~= 0 and lens.af then -- lens is OK
repeat
msleep(100)
until lens.focus(0,1,false)
end
end
function check_bookend() -- adds a differenty exposed frame
if supermenu.submenu["Bookends?"].value == "yes"
then
local tv = camera.shutter.ms
local av = camera.aperture.value
camera.shutter.ms = 1
camera.aperture.apex = 9
my_shoot()
camera.shutter.ms = tv
camera.aperture.value = av
end
end
function go() -- and run the script
local lens_ok = true
local num_step = 0
local del = 0
local count = 0
local inf = 100000 -- pseudo infinity
local pos = 0
menu.close() -- just in case
if lens.af and lv.enabled then -- alright to use script
msleep(supermenu.submenu["Delay"].value * 1000)
check_bookend() -- requested or not
move() -- back to HFD to start super resolution bracketing
count = 0
for count = 1, supermenu.submenu["Number of images?"].value do
count = count + 1
my_shoot()
if count ~= supermenu.submenu["Number of images?"].value then
if supermenu.submenu["Sensor shift mode"].value == "IS Jiggle" then
jiggle(2)
elseif supermenu.submenu["Sensor shift mode"].value == "Lens Move" then
if lens.focus_distance >= inf then
jiggle(2)
else
check_lens_ready() -- just in case
lens.focus(-1,1,false) -- move towards infinity
end
else
if lens.focus_distance >= inf then
jiggle(2)
else
check_lens_ready() -- just in case
lens.focus(-1,1,false) -- move towards infinity
jiggle(2)
end
end
end
msleep(200)
end
check_bookend() -- requested or not
beep (3, 200 , 1000) -- and display message
display.notify_box("Script Finished Running", 5000)
else -- something is wrong
beep (3, 200 , 500) -- and display message
display.notify_box("Sorry, can't use the script", 5000)
end
end
supermenu = menu.new
{
parent = "Shoot",
name = "Super Resolution Bracketing",
help = "Works best with wide lens: be warned!",
depends_on = DEPENDS_ON.LIVEVIEW,
submenu =
{
{
name = "Run Script",
help = "Does what it says after pressing SET",
depends_on = DEPENDS_ON.LIVEVIEW,
select = function(this) if lv.enabled then task.create(go) end
end,
},
{
name = "Number of images?",
help = "Number of super res images to take",
min = 4,
max = 20,
value = 4,
icon_type = ICON_TYPE.BOOL,
select = function(this,delta)
this.value = this.value + delta
if this.value > this.max then
this.value = this.min
elseif this.value < this.min then
this.value = this.max
end
end,
},
{
name = "Delay",
help = "Delays script start by stated number of secs",
min = 0,
max = 5,
value = 0,
icon_type = ICON_TYPE.BOOL,
select = function(this,delta)
this.value = this.value + delta
if this.value > this.max then
this.value = this.min
elseif this.value < this.min then
this.value = this.max
end
end,
},{
name = "Sensor shift mode",
help = "Choose one of three strategies",
choices = {"IS Jiggle","Lens Move","Both"},
},
{
name = "Bookends?",
help = "Places an underexposed frame at start and end of bracket set",
choices = {"no","yes"},
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment