Sunday, July 31, 2022

Depth of Field Scale for Focus By Wire Lenses

Moderm focus by wire lenses are, at first sight, a great idea, but only if the camera matches the technology: which, unfortunately, it doesn't always.

For example, the technology built into the lens to control focusing via wire, eg a stepper motor, doesn't, in the case of Canon, match the UI in the camera, ie there is no or little focus information displayed to help the photographer with, say, focus bracketing.

But it gets worse, as on, say, the EF-M lenses we not only don't have focus feedback via the camera, but we are also missing a depth of field scale, like the good old fashion one shown below:


So I thought I would write my own DoF Scale for the Canon M3 running CHDK. 

The use case is that I'm doing landscape photography and I have a deep focus scene, ie one I can't capture in a single image. In this case the challange is knowing where to focus bracket.

The Quasi Depth of Field Scale (QDFS) script is designed so I can manually focus bracket whenever I need.

The full, base model looks like this (but the script uses a simplified version):

As we are not doing macro photography, and magnification is going to be ‘low’, we can simplfy things a bit, eg assume a symmetrical lens with a pupil mag of unity.

Thus, to create the DoF scale, shown at the bottom right of the above model, all we need to know is the minimum focus distance (M) and the object distance u, both referenced from the front principal.

Rather than attempting to model the actual lens mechanism, we will assume a simple lens focusing arrangement that results in a lens extension F*m, where F is the focal length and m the magnification at u. 

As said above, focusing from the MFD to infinity is achieved by manually rotating the lens, which in this case we track by noting the stepper motor reported position, which we can get from CHDK. As an aside, the stepper motor movement model (every 10 steps) looks like this (F=11, m=0.13, C = 525):

Thus we have a simple equation to solve for u, the object distance from the front principal:

Where C is the maximum stepper motor count at ‘infinity’, n the count at the current focus and m is the magnification at the minimum focus distance, giving us:

Putting n = 0 will give us the model's (sic) minimum focus distance (M), ie in object space, relative to the model's front principal.

A word of caution. QDFS was written to aid focus bracketing. The lens model is not an exact replica of the lens in your camera: it's a model. If used for focus bracketing, including infinity focusing beyond the hyperfocal distance, it will serve you well. If you use to, say, set a singe focus at the calculated hyperfocal, you will likely be out by a few counts. So, if hyperfocal focusing, always focus slightly beyond the hyperfocal and be informed by the QDFS's hyperfocal reporting and the sensor plane based, Canon reported focus distances.

The magnification at the MFD may be measured or taken from the manufacturer's specifications. Zoom can be handled by asuming a linear interpolation between the two zoom extremes, ie accounting for the possibility that the MFD may be different at the zoom extremes.

Plugging the above into the Depth of Field scale model, ie (1-M/u)*k, where k is the scaling for the screen display, we now have a Depth of Field scale for the focus by wire EF-M cameras that run CHDK Lua scripts.

The QDFS (Quasi Depth of Field Scale) script can be download from the right.

As I said above, I wrote QDFS specifically for the 11-22mm EF-M lens, and I would advise not using the script for anything other than a wide angle lens.

The QDFS UI is simple, but, I believe, effective. The scale runs the width of the screen and shows fiducials at the hyperfocal (H), H/2, H/4, H/8, H/16 etc; but you can easly adjust these in the script, eg showing the odds (H/3, H/5, H/7...) or the evens (H/2, H/4, H/6...).

When first run, the script carries out a lens calibration, and does this whenever the focal length changes. The calibration finds the lens stepper motor minimum and maximim counts and the position where 'Canon Infinity' oocurs, ie beyond this count Canon only reports a maximum focus distance. This is needed as some lenses 'max out' their focus reporting before the stepper motor does, like the 11-22m.

The script's menu only has two entires. First the Circle of Confusion you wish to use to set the (overlap, or infinity blur) hyperfocal. Second the option to switch the console on to see some additional data.

With the console switched on, the QDFS UI looks as follows (note the console offset, to the left, is an artifact of the HDMI recording of the screen):


Here we see the DoF scale (white bar) running from the minimum focus to infinity. We also see the hyperfocal marked (red line) and fractions of the hyperfocal (H/2, H/4, H/8 etc).In the screen grab above, at a focal length of 11mm, a CoC of 20 microns and an aperture of F/8, we can just see the H/8 line.

The lower (grey) bar shows the near and far depths of field, either side of the point of focus. This bar will, of course, change in size according to the focal length, aperature and CoC.

The console area shows two lines of information. The top line shows info on the actual stepper motor (max, near and far) counts, and the hyperfocal (from the front principal, ie not the sensor plane)  in mm.

The bottom line shows the current stepper motor position relative to the zeroed MFD, and the Canon reported lower and upper focus distances, relative to the sensor plane.

To illustrate QDFS's functionality, let's take an image at the current point, which represents the nearest object of interest in our scene. Image capture is achieved by using the M3's M-Fn button. We now see the following:


A top bar (blue) now appears and shows the last image's position and depth of field. The focus bar (lower) has turned yellow, indicating that we are still positioned exactly where the last image was captured. We also see the count at the captured image’s location. If we now move focus we will see something like this:


Here we see the focus bar has changed to green, indicating we have a positive focus overlap. Focusing further we see the following:


In the above we see a focus gap has opened up and the focus bar has turned red to emphaisis this. Clearly, in this case, we would reposition for the next shot and, once taken, the screen would look like this:

The QDFS script was written to provide a depth of field scale for manual focus bracketing. I've kept the UI simple, but I welcome any comments on additional functionality.

As usual I welcome any comments on this post or any of my posts.









No comments:

Post a Comment