Hi Atnas!
As you can see, I'm a "Rookie" also. Am hesitant to post a script which are only slight modifications of already quite fundtional one. Hope I don't just add clutter and probably intorduce more errors.
This said, hear goes for what it's worth).
--[[@title AutoHDR.lua
-- Attempt to automate process of creating multiple photos for HDR combining
-- Original by Atnes
-- Converted to LUA and modified by Mac on 07/10/2009
@param a EXP Step
@default a 1
@param b +EXP Step (x/3)
@default b 0
@param c Start Delay(sec)
@default c 3
@param d Bright Limit(29-1023)
@default d 150
@param e Dark Limit(29-1023)
@default e 100
@param f DF Sub(auto=0,off=1,on=2)
@default f 2
@param g Meter(0=ev,1=spot,2=cnt)
@default g 2
]]
function Log(name)
-- Prevents overwriting existing log
local i = 0
repeat
i = i + 1
num = 1000 + i
numstr = string.sub(tostring(num),-3)
path = "A/CHDK/LOGS/"
filename = path..name..numstr
res,msg = io.open(filename)
until not res
io.output(io.open(filename,"a+"))
end
function Delay(sec)
repeat
cls()
print("Starting in ", sec, "sec")
sleep(960)
sec = sec - 1
until sec==0
end
function Record()
io.write("AutoHDR Script\n")
io.write(os.date("%m/%d/%Y %X\n"))
io.write("Uncorrected photo: "..photo.."\n")
Bv=get_bv96() Av=get_av96() Sv=get_sv96() Tv=get_tv96()
io.write("Bv= "..Bv.." Sv= "..Sv.." Av= "..Av.." Tv= "..Tv.."\n")
io.close()
end
function Shot()
sleep(100)
click("shoot_full")
repeat
sleep(10)
until get_shooting()~=true
sleep(500)
Number_of_Shots = Number_of_Shots + 1
photo = get_exp_count()
end
function Initial_Shot()
set_aflock(0)
press("shoot_half")
repeat
sleep(10)
until get_shooting()==true
release("shoot_half")
set_aflock(1)
Shot()
Start_Photo=photo
end
function Record_INFO()
io.output(io.open(filename,"a+"))
sign = 1
Delta_EXP = Delta_EXP/32
--if Delta_EXP is negative, change to positive and set sign to -1
if Delta_EXP < 0 then sign = -1 Delta_EXP = sign*Delta_EXP end
E = Delta_EXP/3
E = 3*Delta_EXP
third = Delta_EXP-E
E = sign*E/3
if third==0 then print(E,"EV") io.write(photo.." h= "..h.." "..E.."EXP\n") end
if third==1 then print(E,"1/3 EV") io.write(photo.." h= "..h.." "..E.."1/3 EXP\n") end
if third==2 then print(E,"2/3 EV") io.write(photo.." h= "..h.." "..E.."2/3 EXP\n") end
io.close()
end
function Bright_Areas()
cls()
print("Light area correction")
Bright_Tv = Tv
--Decrease exposure by EXP_step
repeat
Bright_Tv = Bright_Tv + EXP_Step
set_tv96_direct(Bright_Tv)
Delta_EXP = Tv-Bright_Tv
Shot()
--Check for bright pixels in the histogram
h = get_histo_range(d,1023)
--Display exposure difference from origrinal (Delta_EXP)
Record_INFO()
sleep(100)
--If too bright, use shorter exposure for darker image
until h==0
end
function Dark_Areas()
cls()
print("Dark area correction")
Dark_Tv = Tv
repeat
--Increase exposure by EXP_step
Dark_Tv = Dark_Tv - EXP_Step
set_tv96_direct(Dark_Tv)
Delta_EXP = Tv-Dark_Tv
Shot()
--Check for dark pixels in the histogram
h = get_histo_range(0,e)
--Display exposure difference from origrinal (Delta_EXP)
Record_INFO()
sleep(100)
--If too dark, use longer exposure for brighter image
until h==0
end
function Log_Summary()
io.output(io.open(filename,"a+"))
io.write("Total number of pics: "..Number_of_Shots.."\n")
io.write("Photos taken: "..Start_Photo.." to "..photo.."\n")
Range_Tv = (Bright_Tv - Dark_Tv)/96
io.write("Total exposure range(EXP): "..Range_Tv.."\n")
io.close()
end
--Script Begins
log_name="AutoHDR_"
Log(log_name)
Delay(c)
-- Set exposure mode (0 = evaluation, 1 = spot, 2 = center weighted)
if get_propset()==1 then set_prop(9,g) else set_prop(155,g) end
shot_histo_enable(1)
set_raw_nr(f)
EXP_Step=96*a+32*b
Number_of_Shots=0
Initial_Shot()
Record()
Bright_Areas()
Dark_Areas()
Log_Summary()
set_aflock (0)
set_raw_nr(0)