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.
Theory
The traditional AF calibration process goes something like this:
- Set up target
- Align camera
- Manually focus to infinity
- AF on the target take an image
- dig through menus to get the the AF settings, change the setting slightly
- 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.
- It only works with Canon cameras, specifically those with Live View.
- You must have Canon’s EOS Utility installed.
- You need AutoHotKey_L installed (tested with version 1.1.05.06).
- 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.
Procedure
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.
- Connect the camera to your computer via the USB cable.
- Setup and align your camera and autofocus target as you normally would.
- Set the camera to manual exposure mode.
- 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.
- Set the aperture to it’s widest setting (i.e. f/2.8 on an f/2.8 lens)
- Set the ISO to 100
- 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.
- Start Canon’s EOS Utility
- Make sure that EOS Utility has brought up the remove control panel and is communicating with the camera.
- Double click on the AF Test.ahk script you extracted from the zip file.
- Follow the onscreen prompts from the script.
- 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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
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.
Comments
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.
Robert
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).