Points in Focus Photography

Canon EOS AF Adjust Frame Capture Script

Some time back I wrote about doing AF Adjustments using Live View; at least in Canon’s EOS Utility while in live view mode you can manipulate the lens’s focus position using the AF control system in 3 step sizes from the finest the camera can make to something considerably larger. The key being that an AF micro adjustment step is the same size as the smallest step the AF can be directed to make (1/8th of a depth of field).

At the time I wrote that article, there was also a tool available from Helicon focus that would do the same thing automatically and then use a contrast detection algorithm to determine whether the image was maximally sharp (i.e. dead on in focus). Unfortunately they seem to have removed that feature from their software.

Likewise, a new app has shown up on the scene Reikan’s FoCal. FoCal seems to be doing the same thing that Helicon Focus’s software did, though it seems to do it using a special target. Do note, as of the writing of this I haven’t actually tested FoCal.

I’m not one to get in the way of other people’s businesses, but with the economy and my business the way it is, I have more spare time than spare change; if I can work out a solution that costs me time and not money well that’s what I’m going to do. Which brings me to this post.


The traditional AF calibration process goes something like this:

  1. Set up target
  2. Align camera
  3. Manually focus to infinity
  4. AF on the target take an image
  5. dig through menus to get the the AF settings, change the setting slightly
  6. repeat 3-5 until you’ve either covered all the necessary adjustments or until you find one that works best

However, the AF micro adjusts are essentially just saying to the camera, “when you think it’s in focus, move the lens x steps more”. The whole refocus to infinity and repeat is largely a product of not being able to simply command the AF system to move in small steps from the camera, which is what the live view solution does.

The unassisted live view method is a slight improvement over the unassisted method, in that the live view method only requires one manual focus and AF operation, but requires you to manually advance the focus in EOS Utility (or whatever camera control software you use) and keep track of the number of times you click the button.

Automating Live View Capture

My fist thought was, hey I’m not a useless programmer, I can grab the SDK from Canon and just write up a nice little C# app that does all the camera control stuff for me. Then I realized that the Canon SLR SDK is written in C not C# so instead of just getting down to business, I would have to write a wrapper then write the app. Okay scratch that idea.

Then I remembered AutoHotKey. AutoHotKey is a generic macro program that mimics keyboard and mouse inputs following a script. If it sounds familiar to readers of this site, it’s what I used to work around rather annoying problem I was having with my Wacom tablet drivers crashing. While AutoHotKey can’t do any form of image analysis, it could at least remove the work in capturing the images, and that’s enough for me for now.

Caveats and Prerequisites

There are a couple of caveats with this whole solution.

  1. It only works with Canon cameras, specifically those with Live View.
  2. You must have Canon’s EOS Utility installed.
  3. You need AutoHotKey_L installed (tested with version
  4. You can’t do anything else while the process is running.

The first 3 are pretty straight forward; number 4 is a gotcha. Because this script emulates keyboard and mouse actions, if you start using the keyboard and mouse while the script is running it won’t be able to send the right actions to the right program. I’ve tried to make it as fool proof as possible, but there’s only so much I can do with these tools. As it stands it shouldn’t take more than about 2-6 minutes depending on whether you run the fine or course capture process.

Also while you can’t calibrate those cameras with Live View but without AF Micro-adjusts (like the EOS 40D, or the newer Rebels) you can generate the image stack to see if they are focusing correctly.


After insuring you meet the prerequisites and having the software installed, download the Zip file from the link in the box to the right, and extract it somewhere you can get to (like your desktop). Then follow the steps for building the image stack.

  1. Connect the camera to your computer via the USB cable.
  2. Setup and align your camera and autofocus target as you normally would.
  3. Set the camera to manual exposure mode.
  4. If testing a zoom lens, zoom to the most common focal length you use, alternatively you can repeat the procedure for various focal lengths and use the micro-adjust that best matches all the focal lengths.
  5. Set the aperture to it’s widest setting (i.e. f/2.8 on an f/2.8 lens)
  6. Set the ISO to 100
  7. Adjust the exposure using the shutter speed so that the camera meters correctly (I usually meter at +1/3 to +2/3rds given my environment tends to be on average lighter than 18% gray.
  8. Start Canon’s EOS Utility
  9. Make sure that EOS Utility has brought up the remove control panel and is communicating with the camera.
  10. Double click on the AF Test.ahk script you extracted from the zip file.
  11. Follow the onscreen prompts from the script.
  12. When everything is done, the script will automatically close the EOS Utility live view window and display a notice that capture is complete.

Again, while the capture is running it’s important that you don’t try and do something else on the computer.

The output of the capture will be stored in the director you’ve configured EOS Utility to save images to. The first image will be the one made to set the AF system, you can delete this if you wish, it’s extraneous. The remaining 11 or 41 images are the focus stacks.

If you chose to use the course steps, you’ll have 11 files that correspond in order to micro adjust settings of -20, -16, -12, -8, -4, 0, 4, 8 12, 16, and 20. If you chose fine you’ll have 41 images corresponding to -20 to +20 in 1 step increments.

Interpreting the Results

The easiest way to interpret the results is to load the images into your favorite RAW viewer and page though the images. The one that looks most “on” will be the image that you want to make note of. You just have to count what image that is and convert that to the correct AF micro-adjust step. You can use the tables below to convert the image’s sequence number to an AF Adjust. (Note, this assumes you don’t count or deleted the first image taken.)

Fine Test Sequence Coarse Test Sequence
Image is # in sequence AF Adjust Image is # in sequence AF Adjust
1 -20 21 0
2 -19 22 1
3 -18 23 2
4 -17 24 3
5 -16 25 4
6 -15 26 5
7 -14 27 6
8 -13 28 7
9 -12 29 8
10 -11 30 9
11 -10 31 10
12 -9 32 11
13 -8 33 12
14 -7 34 13
15 -6 35 14
16 -5 36 15
17 -4 37 16
18 -3 38 17
19 -2 39 18
20 -1 40 19
41 20
Image is # in sequence AF Adjust
1 -20
2 -16
3 -12
4 -8
5 -4
6 0
7 4
8 8
9 12
10 16
11 20

After dialing in the AF adjust, take a few manual test images to insure that it is correct. Again, due to the way this script works, it’s possible that a command may not be relayed properly for any number of uncontrollable reasons.

As always, if you find a bug, please leave a comment here, or email the contact address in the script, and I’ll try and address it.



Hello, I have a 50D + 28mm f1.8 lens and I’m having problem with the lens front focus issue. I came across your post while searching for microadjustment tips. Your post is very helpful. However, when I tried to download the script that you post on your site, it gave me error message “file could not be read”. May I have the link to your script? Please kindly shoot me an email with the working link to your awesome script. Thank you very much for your time and effort.


V. J. Franke  | admin

Robert, the download works fine for me by clicking on the link in the post; in IE, Firefox, and Chrome even. It’s entirely possible that my server, your Internet connection, or any of the numerous bits and bobs in between threw a wobbly and corrupted something when you were trying to download it.

The link in the article is a direct link to the file.

Just in case there was something wrong with the file I’ve recompressed it and re-uploaded it. Try here: http://static1.pointsinfocus.com/2012/01/canon-eos-af-adjust-frame-capture-script/EOS-Utility-AF-Test-Automation.zip (the link in the post should reflect this URI as well).

Leave a Reply

Basic Rules:
  • All comments are moderated.
  • Abusive, inflamatory, and/or "troll" posts will not be published.
  • Links to online retailrs (eg., Amazon, Ali Express, EBay, etc.) either directly, or indirectly through 3rd party URL shorternrs, will be removed form your post.
  • Extremely long comments (>1000 words) may be blocked by the spam filters automatically.
  • If your comment doesn't show up, it may have been eaten by the spam filters; sorry about that.
  • See the Terms of Use/Privacy Policy for more details.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Follow me on twitter for updates on when new comments and articles are posted.

Email Notice Details: By checking the above checkbox, you are agreeing to recieve one email at the email address provided with this comment, for the sole purpose of notifing you that the article author has been reseponded to your comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Our cookie and privacy policy. Dismiss