But upon some more thought overnight, it makes sense. The lens equation is 1/i + 1/o = 1/f where i, o and f are the image distance, object distance and focal length respectively. If you write it as o = 1/(1/f - 1/i) you can take the derivative do/dx to see how the "object position" (i.e. the value returned by get_focus()) varies with change in image position (i.e. the actual position of the lens above the sensor), and it blows up when i=f. So that makes sense. When you are focusing the lens at "infinity", any very small change in the lens position results in a huge change in calculated "object" position. So I am not sure there is anything useful to be learned from the returned object position.
It tells you *something* about the position, I would expect different reported "subject distance" reflect different lens positions. E.g. on my g7x, ~130000 is different from 195000. So you could step set_focus values from say, 100k to 200k, note when the get_focus() changes, and check each distinct get_focus() step (including where it goes to -1) for focus quality. However, if best focus isn't at one of the points set_focus lands on, you're SOL.
I've actually been meaning to add something like this to fixedint, since trying to focus using the LCD screen is one of the major pain points. My idea is to evaluate contrast on the raw image using
rawop, perhaps restricted to point sources. This would be similar to camera AF, except done on full resolution raw data and restricted to limited range.
Is there a way to set the lens in a more raw fashion - i.e. native camera "clicks" or whatever it is? Then we could possibly command the lens to go out *past* infinity focus and come *in* to the desired point. Not sure that would work any better, but it would be nice to be able to try it.
There has been some experimentation:
https://chdk.setepontos.com/index.php?topic=11078.msg130083#msg130083Also some related work on EOS M cameras
https://chdk.setepontos.com/index.php?topic=12542.msg140739#msg140739 (not directly relevant to P&S, they use different functions)
P.s. and yes, also same thing on the G16. The Manual Focus bar goes to full at infinity focus, but there is a little arrow at the top of it. I can click the focus position 11 times more and then the arrow goes away. But is the focus really "beyond infinity" when clicking beyond the full bar? I need to try that.
On my G7 X, it definitely is, focus gets progressively worse at steps beyond infinity. There are actually a few steps beyond where the arrow disappears.
We really need a set_lens_position() command rather than a set_focus() command.
That would certainly be desirable, but it needs some R&D to figure how to support it across > 100 models. Focus override has already been a problem area.
The set functions are like MoveFocusLensToPosition*, MoveFocusLensWithPosition* and MoveFocusPosition. Usage, limits, safety need to be determined by reverse engineering and experiment. There is also MoveFocusActuator
Other possibly interesting functions
GetFocusLensPositionRatio
ChangeFocusDistanceToPosition
GetFocusLensMoveMaxPosition / GetFocusLensMoveMinPosition