Auto focussing by moving the camera

A forum to ask questions, post setups, and generally discuss anything having to do with photomacrography and photomicroscopy.

Moderators: rjlittlefield, ChrisR, Chris S., Pau

cvhmanchester
Posts: 5
Joined: Fri Jan 04, 2019 3:49 pm
Location: Manchester UK
Contact:

Auto focussing by moving the camera

Post by cvhmanchester »

In digital cameras, automatic focussing by changing the lens extension is really good, but it does result in changing the magnification. I am trying to make a mosaic of macro photos (up to 1200) in order to create a composite. But the surface is slightly uneven, so parts of the mosaic are slightly out of focus. The compositing software has to make even more compromises to join the dots.

The necessary tools exist to provide the best focus at a specified distance/ magnification in real time, so all the images are at the same magnification and in best focus:

1. a digital method to identify the position of maximum sharpness of the image

2. a mechanical method to move the camera minutely to that point.

Has anyone integrated these two tools?

The algorithm to quantify the quality of focus and to estimate the direction towards better focus is common in most cameras. It would be good to use the camera's output of that process to feed into a position control of the camera (instead of the lens extension).

Alternatively, most cameras have the ability to output the viewed image to an external image processor, where the focus algorithm would do its analysis, then output a movement command.

I use an Olympus E-M5 ii, but the principle should be adaptable to and from many platforms.

Has anyone combined these to create a workable system?

Thank you for your ideas.

Pau
Site Admin
Posts: 6051
Joined: Wed Jan 20, 2010 8:57 am
Location: Valencia, Spain

Re: Auto focussing by moving the camera

Post by Pau »

I have dreamed with such a system, both for autofocus and autostacking. :-k

Theoretically this could be done if you take the focusing electric signals from the objective bayonet camera mount and feed with them a motor similar to the lens focus one but driving the rail. But usually rail motors are much stronger than lens ones.
A camera and rail designed to work together would be much more convenient, of course. This would be doable for major camera makers although I don't see enough market for it.

There must exist for sure industrial systems that do it and there also do exist microscope autofocus systems
Pau

dolmadis
Posts: 899
Joined: Wed Dec 07, 2011 1:51 pm
Location: UK

Re: Auto focussing by moving the camera

Post by dolmadis »

cvhmanchester wrote:
Fri Jan 22, 2021 3:48 am
In digital cameras, automatic focussing by changing the lens extension is really good, but it does result in changing the magnification. I am trying to make a mosaic of macro photos (up to 1200) in order to create a composite. But the surface is slightly uneven, so parts of the mosaic are slightly out of focus. The compositing software has to make even more compromises to join the dots.
I might be wrong but are you describing what has often been discussed here as a Stack & Stitch System (S&S)?

If it is then a search would find these discussions and applications.

What I have been unable to glean from your post is the size of the subject you have in mind though.

Best, John

elf
Posts: 1416
Joined: Sun Nov 18, 2007 12:10 pm

Re: Auto focussing by moving the camera

Post by elf »

It sounds like you want a spherical macro panorama setup. In order for one to work, the entrance pupil of the lens needs to be at the rotation point of the spherical panorama jig. This implies using bellows to control the focus for focus stacking or moving the subject.

If you want to do orthogonal panoramas, then you'll want a telecentric lens.

cvhmanchester
Posts: 5
Joined: Fri Jan 04, 2019 3:49 pm
Location: Manchester UK
Contact:

Re: Auto focussing by moving the camera

Post by cvhmanchester »

Thank you for the ideas. I shall look into the industrial/microscope systems.

The mosaic is prepared by scanning the camera across the surface on a robotic gantry, see photo, with multiple tesserae taken normally (as best as I can manage). The paper sheet is distorted by the initial printing pressure and 200 years of environmental changes. Squashing the paper with a glass sheet can improve the flatness, but can lead to distortion, even creasing. So I should like to shift the camera's focus plane to follow the paper surface as much as possible as the gantry scans across the surface, i.e. maintaining the same magnification.

Unfortunately, Olympus was very helpful - but only within the limits of the initial design spec of the camera. Any adaptation of the hard or software was not considered. With change of ownership, it seems even less likely that thinking outside the box to extend their cameras' applications will be encouraged or supported.
It seems unlikely that Capture even receives a measurement of the degree of sharpness. Has Olympus made any technical analysis software that can extract that information from the camera's internal automatic focussing program?

The required steps seem to be:
1. capture the lens image from the camera on the PC.
2. load this image into image analysis software
3. analyse the degree of sharpness (fortunately the features are fairly contrasty grey and white)
4. move camera a bit using a step motor (I can reuse one from focus stacking kit)
5. repeat 1-4 until the maximum sharpness is reached
6. take the photo
7. move to the next position
8. repeat for the sequence of photos

The current setup achieves steps 6-8 very well to create a mosaic that can be composited.
Step 1 may be achievable using the HDMI video output socket to capture a x14 zoom camera image.


Any advice on steps 1-5 gratefully received.
Thank you

elf
Posts: 1416
Joined: Sun Nov 18, 2007 12:10 pm

Re: Auto focussing by moving the camera

Post by elf »

I think Zerene Stacker makes steps 2 and 3 unnecessary. IIRC, Zerene Stacker adjusts the individual images in a stack to the magnification of the first image. This means all you need to do for subsequent frames in the panorama is to start at the same Z position.

Pau
Site Admin
Posts: 6051
Joined: Wed Jan 20, 2010 8:57 am
Location: Valencia, Spain

Re: Auto focussing by moving the camera

Post by Pau »

Some more non ellaborated ideas:

Maybe tedious due to the big amount o pictures to check but if the focus difference between stitch positions is not big you could just do a short focus bracketing with a stacking rail at each position and manually select the best frame.

Another option could be to use an external AF system, I remember slide projectors having infrared autofocus based in the reflection on the film plane...

Not being an engineer, I have ideas which I don't know how to implement, sorry
Pau

Chris S.
Site Admin
Posts: 4042
Joined: Sun Apr 05, 2009 9:55 pm
Location: Ohio, USA

Re: Auto focussing by moving the camera

Post by Chris S. »

I've naively supposed that in concept, it might not be difficult to intercept a camera's autofocus instructions intended for its own lenses, and co-opt these instructions to drive the stepper motors in our macro rigs. The point of such thinking is this: Most modern cameras have sophisticated autofocus, and it might be far easier to co-opt this autofocus than to reinvent it. Also, even cameras with very "smart" autofocus must give simple instructions to lenses, which are not so smart. These instructions to the lens may well be as simple as "move forward" and "move backward."

It may be worth mentioning that third party lens makers are likely already doing this for at least some brands of camera, where the camera maker refuses to disclose focus protocols. Yet many third party lenses autofocus very well.

On the simple side, some Nikon bodies have at least two ways of actuating autofocus--one for legacy lenses, and one for more modern lenses with fancier autofocus motors. For the older lenses, the autofocus interface consists of a screw shaft coming out of the camera, and a mating screw shaft on the lens; the lens has no motor, and its elements are turned by the screw shaft in the camera body. While I would not use this in-camera shaft to focus a linear-stage macro rig, it seems feasible to measure the turns of this shaft and program a micro-controller to move a stepper motor accordingly to advance/retract the linear stages on which our macro rigs sit.

For more modern lenses on Nikon and other brands, contacts on the camera mount seem to be instructing rapid motors on the lens to move forward or backward. With a little work, shouldn't it be possible to use multimeters and oscilloscopes to characterize these signals from the camera? Then, using this information, program a microcontroller, to intercept these signals, interpret them, and send appropriate instructions to our stepper motors?

This is not of particular interest to me, so I've never tried it. What I would find a bit more interesting: A feature that automatically shoots a stack "from mush to mush"--shooting every portion of the subject that shows any detail, plus some detail-less mushy regions to front and back of it. I'm pretty sure I could program this, but the time to create it would be far greater than the time saved. It comes to mind that Zerene Stacker can already drive the Cognisys controller, and that contrast recognition (likely a good basis for differentiating between "mush" and "useful frame"?) is already a core capability of Zerene.

So Rik, any chance that such a thing could go on the Zerene Stacker wish list? (If it did, I'd certainly want the ability to add a safety parameter at each end.)

--Chris S.

Post Reply Previous topicNext topic