Hello again,
I've improved the script a bit further. In CarLapseV4 I introduced the possibility to PAUSE and RESUME the shooting by button-presses. That's a nice feature when you are waiting at red traffic lights or get into a traffic jam. CarLapseV5 now uses "Motion Detection" to automatically realize if you are in movement with your car or not... If you are not (e.g. when you are waiting at traffic lights) it will PAUSE and RESUME shooting instantly when you start driving again. :-)
Here's the script :-)
--[[
@title CarLapseV5
-- Author: careyer
@param a Frame delay (sec)
@default a 0
@param b Max. TV (1/sec)
@default b 125
@param c Default ISO (*100)
@default c 1
@param d Maximum ISO (*100)
@default d 16
@param e Loop X times (0=endless)
@default e 0
@param f AutoISO (0=No,1=Yes)
@default f 1
@param h Pause on MD (0=No,1=Yes)
@default h 1
@param p Check every X frame
@default p 10
@param i MD colums (def: 6)
@default i 6
@param j MD rows (def: 4)
@default j 4
@param k MD first colum (def: 3)
@default k 3
@param l MD last colum (def: 4)
@default l 4
@param m MD first row (def: 2)
@default m 2
@param n MD last row (def: 3)
@default n 3
@param r Focus to Inf.(0=no, 1=yes)
@default r 1
@param s JPG Q:-1..2=off,best..norm
@default s -1
@param t JPG resol.(-1=off,see doc)
@default t -1
@param g Startup Delay (seconds)
@default g 2
@param u Startup Delay (minutes)
@default u 0
]]
-- Converting thresholdTV to TV96 representation
-- rounding to next faster shutterspeed if needed
thresholdTV = b
thresholdTV96 = 0
if thresholdTV == 2 then
thresholdTV96 = 96
elseif thresholdTV == 3 then
thresholdTV96 = 160
elseif thresholdTV == 4 then
thresholdTV96 = 192
elseif thresholdTV == 5 then
thresholdTV96 = 224
elseif thresholdTV == 6 then
thresholdTV96 = 256
elseif thresholdTV >= 7 and thresholdTV <=8 then
thresholdTV96 = 288
elseif thresholdTV >= 9 and thresholdTV <=10 then
thresholdTV96 = 320
elseif thresholdTV >= 11 and thresholdTV <=13 then
thresholdTV96 = 352
elseif thresholdTV >= 14 and thresholdTV <=15 then
thresholdTV96 = 384
elseif thresholdTV >= 16 and thresholdTV <=20 then
thresholdTV96 = 416
elseif thresholdTV >= 21 and thresholdTV <=25 then
thresholdTV96 = 448
elseif thresholdTV >= 26 and thresholdTV <=30 then
thresholdTV96 = 480
elseif thresholdTV >= 31 and thresholdTV <=40 then
thresholdTV96 = 512
elseif thresholdTV >= 41 and thresholdTV <=50 then
thresholdTV96 = 544
elseif thresholdTV >= 51 and thresholdTV <=60 then
thresholdTV96 = 576
elseif thresholdTV >= 61 and thresholdTV <=80 then
thresholdTV96 = 608
elseif thresholdTV >= 81 and thresholdTV <=100 then
thresholdTV96 = 640
elseif thresholdTV >= 101 and thresholdTV <=125 then
thresholdTV96 = 672
elseif thresholdTV >= 126 and thresholdTV <=160 then
thresholdTV96 = 704
elseif thresholdTV >= 161 and thresholdTV <=200 then
thresholdTV96 = 736
elseif thresholdTV >= 201 and thresholdTV <=250 then
thresholdTV96 = 768
elseif thresholdTV >= 251 and thresholdTV <=320 then
thresholdTV96 = 800
elseif thresholdTV >= 321 and thresholdTV <=400 then
thresholdTV96 = 832
elseif thresholdTV >= 401 and thresholdTV <=500 then
thresholdTV96 = 864
elseif thresholdTV >= 501 and thresholdTV <=640 then
thresholdTV96 = 896
elseif thresholdTV >= 641 and thresholdTV <=800 then
thresholdTV96 = 928
elseif thresholdTV >= 801 and thresholdTV <=1000 then
thresholdTV96 = 960
elseif thresholdTV >= 1001 and thresholdTV <=1250 then
thresholdTV96 = 992
elseif thresholdTV >= 1251 and thresholdTV <=1600 then
thresholdTV96 = 1021
elseif thresholdTV >= 1601 and thresholdTV <=2000 then
thresholdTV96 = 1053
end
require "fb-lib"
propcase=require("propcase")
-- verbose=1 gives more printout during shoot
verbose=0
min_delay=check_range(a,0,10000)
max_tv=sec_to_tv96(check_range(b,1,65))
default_sv=ISO_to_sv96(check_range(c,0,21)*100)
max_sv=ISO_to_sv96(check_range(d,0,21)*100)
maxISO = d*100
-- select focus distance (user specified if parameter r<=0, infinity otherwise):
if r>0 then subjdist=65535
else subjdist=get_focus()
end
-- jpg quality -1=do not change, 0=super fine, 1=fine, 2=normal,
jpg_quality=check_range(s, -1, 2)
if jpg_quality>-1 then
set_prop(propcase.QUALITY, jpg_quality)
end
-- jpg resolution -1=do not change, others are whatever they are in your camera:
-- For a570is Digic III: 0,1,2,3,4,6,8 = L,M1,M2,M3,S,Postcard,W
-- For s3is Digic II: 0,1,2, 4, 8 = L,M1,M2, S, W
-- We can probably assume those numbers are always the same, but availability may vary.
jpg_resolution=check_range(t, -1, 8)
if jpg_resolution>-1 then
set_prop(propcase.RESOLUTION, jpg_resolution)
end
startupdelay=check_range(u, 0, 65535)
startupdelaySec = g
-- startup delay if requested
if startupdelay>0 then
for remaining=startupdelay,1,-1 do
print("Sleeping ", remaining, " minutes")
sleep(29980)
sleep(29990)
end
end
if startupdelaySec>0 then
for remaining=startupdelaySec,1,-1 do
print("Sleeping ", remaining, " seconds")
sleep(1000)
end
end
-- enable shot histogram
shot_histo_enable(1)
-- start counting frames
count_frames=1
-- store script start time and disk space at the beginning:
starttick=get_tick_count()
startdiskspace=get_free_disk_space()
-- next_shoot keeps the time (in get_tick_count units) when next shot should be taken.
-- initialise next_shoot to "shoot now"
next_shoot=0
-- force manual focus (does this work?)
set_prop(propcase.FOCUS_MODE,1)
-- disable IS (dunno if this works either)
set_prop(propcase.IS_MODE,3)
-- use widest available aperture (I'm assuming that cameras that don't have an aperture won't respond to this in any way)
set_prop(propcase.USER_AV,get_prop(propcase.MIN_AV))
-- disable flash
set_prop(propcase.FLASH_MODE,2)
-- initializing Focus: setting Focus-Lock
press("shoot_half")
repeat
sleep(1)
until get_shooting() == true
set_focus(subjdist)
sleep(1000)
press("left")
sleep(100)
release("left")
release("shoot_half")
-- main loop. the program loops forever unless you interrupt it
loopcounter=0
mdcounter=0
repeat
mdcounter=mdcounter+1
wait_click(100)
if is_pressed "display" then
print("Paused by user")
repeat
wait_click(100)
until is_pressed "menu"
print("Continued by user")
end
loopcounter = loopcounter+1
-- now wait for the time to do next shot
repeat
sleep(1)
tick=get_tick_count()
until tick>=next_shoot
-- Reset ISO to default value (ISO 100)
sv96ISO = 419
set_sv96(sv96ISO)
-- Measuring TV at default ISO
press("shoot_half")
repeat
sleep(1)
until get_shooting() == true
-- get metered day exposure
bv=get_bv96()
av=get_av96()
tv=get_tv96()
t = 0
-- Detect Motion ---
if h>0 and mdcounter==p then
repeat
sleep(1)
t = md_detect_motion(i, j, 1, 40, 15, 5, 1, t, 1, k, m, l, n, 0, 6, 0)
until t>0
mdcounter=0
end
release("shoot_half")
-- Check if TV slower than allowed value and raise ISO if needed
shoot_sv = default_sv
difference = 0
differenceFactor = 0
sv96ISO = 419
isoString = 100
difference = thresholdTV96 - tv
differenceFactor = difference/96
differenceRemainder = difference-(differenceFactor*96)
-- Raising ISO and adjusting TV if needed
while difference>0 and isoString<maxISO do
difference = difference-96
isoString = isoString*2
sv96ISO = sv96ISO+96
tv=tv+96
end
-- correcting TV value to match closest TV96 value
count = 0
while tv>32 do
count = count+1
tv=tv-32
end
tvremainder = tv
if tvremainder >=16 then
tv = (count*32)+32
else
tv = count*32
end
-- set ISO and TV for next shot,
set_sv96(sv96ISO)
set_tv96(tv)
press("shoot_half")
repeat
sleep(1)
until get_shooting() == true
set_focus(subjdist)
press("shoot_full")
release("shoot_full")
release("shoot_half")
-- wait for shooting to finish
repeat
sleep(1)
until get_shooting() ~= true
-- print out remaining disk space estimates in terms of frames and time:
print(count_frames .." ISO " .. isoString )
count_frames=count_frames+1
-- we are now ready to shoot, calculate the next shot time
next_shoot=tick + min_delay*1000
-- return to top, where we will wait to shoot
if (e == loopcounter) then
break
end
until 1==2
BTW: You can of course configure in what time interval the script will check if you are still in movement. To keep the intervalls short you should not check on every frame.
Cheers!