1000ms should be more than enough, but sometimes I see the diagnostic "C" and "C done" come up almost immediately. Is that Sleep command reliable? What happens then is that it isn't in AF frame moving mode when it should be, and the remaining photos get taken with the AF frame in the centre. Sometimes it works great.
I've worked out the problem, it needed a Sleep after the Shot command. Working reliably now, but it could really do with some optimisation of the AF frame movements. The Sleeps after Shot command and in the AF frame recentring gosub need some experimentation to see how much they can be reduced too.
It would be great if there was a property I could set for the AF frame location instead of manually moving it, as that would greatly increase the speed and reduce the complexity of the script.
I'd be interested to hear what results people get if they try the script.
Here's the corrected script:
rem Based on original script by MLuna - based om MX3 sample script
rem 29 Jan 2009 pshute
rem Added value of 4 to param "a" (Shot). When set to 4, camera will detect movement
rem using all but the outer cells of a 5x5 grid. When motion is detected, a shot with
rem AF is taken for each cell where a change was recorded, after first moving the AF frame
rem over that cell.
rem Tested on S3IS only
rem Use with caution!
rem vars used: a-k, l-n, t, H-J, T-V, X
@title Motion Detection with variable AF frame
rem Shot without auto-focus/with auto-focus/continuously (need to put in continuous mode manually)
rem T implies test mode with MD cells drawing and no shots taken
@param a Shot (0=nf/1=f/2=c/3=t/4=af))
@default a 1
rem How long the shutter button will be pressed in continuous mode
@param b Continuos shoot (secs)
@default b 10
@param c Threshold (0-255)
@default c 5
@param d Compare Interval (msecs)
@default d 20
@param e Compare Interval (secs)
@default e 0
rem If this value is too small, the camera goes continuously shooting after the 1st shot.
rem Experiment with this value to find one fitted to your needs
@param f Begin Delay (secs)
@default f 5
@param g Pix step(speed/accuracy adj)
@default g 5
@param h Columns
@default h 6
@param i Rows
@default i 6
rem Frame width in which no MD is performed (in cell units)
@param j Dead frame
@default j 0
if a<0 then let a=0
if a>4 then let a=4
if c<0 then let c=0
if d<0 then let d-0
if e<0 then let e=0
if g<1 then let g=1
if h<1 then let h=1
if i<1 then let i=1
if j<0 then let j=0
rem If varAF mode set 5 rows and cols with 1 dead zone
if a<>4 then goto "notVarAF"
h=5
i=5
j=1
:notVarAF
rem Conversions secs to msecs
let b=b*1000
let e=e*1000
let f=f*1000
let d=d+e
rem This is the timeout in msecs. After this period, the motion trap is rearmed.
let T=600000
rem Parameters for the Dead Frame
let J=j+1
let H=h-j
let I=i-j
let t=0
let k=0
print "press Shutter Button to Stop"
:repete
if a=0 then press "shoot_half"
md_detect_motion h, i, 1, T, d, c, 1, t, 1, J, J, H, I, 0, g, f
print t,"cells triggered"
if a=0 and t>0 then click "shoot_full"
if a=1 and t>0 then shoot
if a=2 and t>0 then goto "continuos"
if a=3 then goto "test"
if a=4 and t>0 then gosub "varAF"
let t=0
goto "repete"
:varAF
for n=2 to 4
for m=2 to 4
md_get_cell_diff m,n,p
print m,n,p,c
if (p*p)<(c*c) then goto "noVarAFshoot"
gosub "AFframeCentre"
if m=2 then gosub "AFframeLeft"
if m=4 then gosub "AFframeRight"
if n=2 then gosub "AFframeUp"
if n=4 then gosub "AFframeDown"
shoot
sleep 1000
:noVarAFshoot
next m
next n
return
:continuos
let X=get_tick_count
press "shoot_full"
:contloop
let U=get_tick_count
let V=(U-X)
if V<b then goto "contloop"
release "shoot_full"
goto "repete"
:test
if t>0 then let k=k+1
if t>0 then print k," Detected cells: ",t else print "No detection in 10 min!"
let t=0
goto "repete"
:AFframeCentre
print "C"
press "set"
sleep 1000
release "set"
click "set"
print "C done"
return
:AFframeUp
print "U"
click "set"
for l=1 to 6
click "up"
next l
click "set"
return
:AFframeDown
print "D"
click "set"
for l=1 to 6
click "down"
next l
click "set"
return
:AFframeLeft
print "L"
click "set"
for l=1 to 10
click "left"
next l
click "set"
return
:AFframeRight
print "R"
click "set"
for l=1 to 10
click "right"
next l
click "set"
return
end