Focus Bracketing Take a set of images at different focus settings.



Introduction

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 than the current one, the second at the current focus, and the third at a focus bigger than 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 CombineZP.

Written for: Canon A640
Also works on: PowerShot S3, PowerShot A590IS, Powershot A560, SD600/Ixus 60, all Other Canon AXXX (Not tested).
Doesn't work on: Ixus 850 IS (crashes camera)


Parameters (Save as "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.
Note: Some cameras, for example the SD600 don't have a manual focus mode, however focusing the image in the normal way for the first shot seems to work, as the subsequent focusing is done by the script.
  • Number of Pics (Odd) (Default=5)
  • Focus Step Size (x6) (Default=1)
  • Initial Delay (Sec) (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
@param c Initial Delay (Sec)
@default c 1

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

print "Pics:"; a*2+1 , "Step:"; b

sleep c*1000

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

Download and Installation

This script is freeware. Before you can install it, you need to download and install the CHDK Firmware Extension for your specific Canon camera. CHDK is freeware and can be downloaded for a broad range of Canon PowerShot and Digital Ixus cameras here. If you own a Canon A640, you can download a specific build here, which already contains all the CHDK scripts from this site, including the one mentioned above. Copy all the files in this archive to the root of your SD card. If you have problems installing CHDK, please refer to the CHDK Wiki Pages.


Disclaimer

This software and the accompanying files are supplied "as is", without any express or implied warranty. In no event shall the author be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages from the use of this software. By using this software you agree with these conditions.

Copyright © 2007 by Johan Van Barel. All Rights Reserved