Magic Lantern Forum

Developing Magic Lantern => Scripting Corner => Topic started by: gkuenning on December 30, 2016, 07:55:58 AM

Title: Automatic AF microadjustment test shots
Post by: gkuenning on December 30, 2016, 07:55:58 AM
I've come to the conclusion that the "dot-tune" AF method isn't all that reliable, primarily because it's highly sensitive to how well you set the initial hand focusing.  Instead, I'm looking at the method described by epsiloneri: http://www.canonrumors.com/forum/index.php/topic,411.msg5364.html%22%20%5Cl%20%22msg5364 (http://www.canonrumors.com/forum/index.php/topic,411.msg5364.html%22%20%5Cl%20%22msg5364).  That goes back to the old method of taking test shots at every microfocus setting and then analyzing them--except the analysis is mathematical instead of by eyeball.

I'm working on automating the analysis part, but right now I'm taking the test shots by hand.  Given that there's already a dottune script, it seems like it should be possible to write a lua script something like the following pseudocode:


set one-shot AF, single-shot mode, focus on half shutter press
for offset from -20 to 20
    set AF microadjustment to offset
    for testpic from 0 to N-1
        if testpic mod 2 == 0
            drive focus to infinity
        else
            drive focus to near limit
        endif
        autofocus
        press shutter


For N = 4 (as in the original post) this would take 164 frames, four
at each microfocus setting, with half driven in in each direction.
I think that would give enough information for a reliable statistical
analysis.  (I've been doing it by hand so far, but that's tedious and
error-prone.)

Am I correct that this script is possible?
Title: Re: Automatic AF microadjustment test shots
Post by: a1ex on December 30, 2016, 08:59:33 AM
Possible, but you need to be in LiveView for changing focus manually, and outside LV (or in quick AF mode) to autofocus with phase detection. This will increase the number of shutter actuations.

For test images, if you use the quick AF method, you can go to 5x zoom and take silent pictures.

Quote from: gkuenning on December 30, 2016, 07:55:58 AM
I've come to the conclusion that the "dot-tune" AF method isn't all that reliable, primarily because it's highly sensitive to how well you set the initial hand focusing.

Proof, please.

To get good repeatability, you can perform the initial focusing in 5x zoom mode, with contrast-detection autofocus.
Title: Re: Automatic AF microadjustment test shots
Post by: gkuenning on December 30, 2016, 09:52:22 AM
QuoteProof, please

The proof is in the method: even proponents of dot-tune point out that it's critical to get the initial focus correct.  Not every lens can be focused sufficiently accurately by hand; the focus ring isn't always precise.

Try to nail focus with, e.g., an EF 70-200 f/2.8 IS I.  Zooming to 10X doesn't help; tiny movements of the focus ring don't necessarily produce a clear difference in focus, yet they are sufficient to give you different dot-tune results.  Here's a simple experiment: focus your 70-200 as well as you can and run dot-tune.  Then tweak the focus ring ever so slightly and try again.  Same results?  Now defocus to 1.4m, refocus by hand in LV, and try a third time.  If you get the same result all three times then you're doing well with dot-tune, and why should I criticize that?

On the other hand I get inconsistent results with that lens.  The advantage of taking actual images is that you're measuring the autofocus system itself.  There's no proxy involved, no human hand-tuning.  Yes, it runs up your shutter count a bit, but I'm not concerned about a fraction of a percent of my total actuations.

Also, there's no need to go into and out of live view.  The tedious hand procedure for a USM lens is this: go into AFMA menu, select a value.  Twist focus ring to infinity, push shutter, twist, repeat.  Twist focus ring to near limit, push shutter, twist, repeat.  Then return to AFMA and choose a new value.  It's much more painful with a non-USM lens like the 50mm f/1.8, but that's part of why I want to automate the procedure.  I believe that ML can drive the lens to either limit programmatically, just like it can drive it to the hyperfocal point.
Title: Re: Automatic AF microadjustment test shots
Post by: a1ex on December 30, 2016, 01:43:22 PM
Quote from: a1ex on December 30, 2016, 08:59:33 AM
To get good repeatability, you can perform the initial focusing in 5x zoom mode, with contrast-detection autofocus.

You did not consider the above advice in your proof.
Title: Re: Automatic AF microadjustment test shots
Post by: gkuenning on December 31, 2016, 12:29:55 AM
Well it's true that using contrast detection gives somewhat more consistent results--for some cameras and some lenses.  But I still got results from -5 to 0 with the 70-200 f/2.8 on the 50D, and +3 to +8 with the 50mm f/1.8 on the 5D IV (which might or might not be able to use contrast AF in live view--I know it uses dual pixel phase detection in at least some modes and I think in all).  So there's still an argument for analyzing actual photos.

The nice thing is that I looked at the dot-tune code (I didn't realize it was C rather than Lua) and I think it would be pretty easy to use it as a guide for writing the plugin I suggested.  Maybe I'll even find the time to do it in the future.
Title: Re: Automatic AF microadjustment test shots
Post by: a1ex on December 31, 2016, 11:13:53 AM
Okay, looking forward to seeing actual numbers from this experiment.
Title: Automatic AF microadjustment test shots
Post by: DeafEyeJedi on January 01, 2017, 12:14:16 AM
Quote from: a1ex on December 31, 2016, 11:13:53 AM
Okay, looking forward to seeing actual numbers from this experiment.

+1 and thanks for sharing @gkuenning!