CHDK/uBASIC/Scripts/CanonA640: Focus Bracketing

Focus Bracketing

 * Written for/on: Canon A640
 * Also works on: Other Canon AXXX (Not tested)

Focus Bracketing by Johan Van Barel (http://www.vanbarel.com)

The Canon A640 has an impressive macro mode. "Disadvantage" can be the very limited DOF (Depth Of Field). The purpose of this script is to take a set of images at different focus settings around the current focus.

So if you take 3 pictures, it will take the first picture at a focus smaller then the current one, the second at the current focus, and the third at a focus bigger then the current one. The steps are calculated so that they are not linear and thus more natural. You can later stitch the images together with an image stacking program like CombineZM (http://www.hadleyweb.pwp.blueyonder.co.uk/CZM/combinezm.htm)

Documentation/Help (save as a small FocusBracket.txt" file to your /CHDK/SCRIPTS/ folder)

Select P,Tv,Av,M or C mode on your Canon A640 Set the focus to manual focus and focus your image.

Parameters:


 * Number of Pics (Odd) (default=5)
 * Focus Step Size (x6) (default=1)

Script Code (save as "FocusBracket.bas" to your /CHDK/SCRIPTS/ folder)

rem Johan Van Barel 23-07-2007 rem Focus-Bracketing for Canon A640

@title Focus Bracket (Set Focus Manual) @param a Number of Pics (Odd) @default a 5 @param b Focus Step Size (x6) @default b 1

a=a/2 if a<1 then let a=1 if b<1 then let b=1

sleep 500 get_focus f

for s=-a to a   g=f if s<0 then gosub "negative" if s>0 then gosub "positive" print "Pic", s+a+1, "Focus", g; "mm" if g<62 then let g=62 if g>65535 then let g=65535 set_focus g   shoot next s set_focus f

end


 * negative

for i=s to -1 g=6*g/(b+6) next i return


 * positive

for i=1 to s       g=g*b/6+g next i return