Lens movement/focus control - General Help and Assistance on using CHDK stable releases - CHDK Forum supplierdeeply

Lens movement/focus control

  • 34 Replies
  • 5298 Views
Lens movement/focus control
« on: 23 / January / 2023, 13:59:54 »
Advertisements
@reyalp  @anyone


I’m playing around with some ideas and hope you can answer a question I have regarding G5X and G7X, ie Powershot cameras, not interchangeable lens cams like the M3.


Clearly there is a way to move the camera to a specific mm distance, ie  set_focus.


What I’m looking for is a Lua way to know the total lens (rotation) step from where you are focused to the minimum and infinity, and be able to move, ie rotate, the lens a given number of (rotation) steps.


Do you know if this is possible?


Cheers


Garry

*

Offline reyalp

  • ******
  • 14118
Re: Lens movement/focus control
« Reply #1 on: 23 / January / 2023, 15:37:14 »
What I’m looking for is a Lua way to know the total lens (rotation) step from where you are focused to the minimum and infinity, and be able to move, ie rotate, the lens a given number of (rotation) steps.
Well, there is the GetFocusLensCurrentPosition eventproc, which returns a "position" in unspecified units which is presumed to somehow relate to underlying hardware positions, as well as "set" functions which work in presumably the same units. See https://chdk.setepontos.com/index.php?topic=11078.msg130083#msg130083 https://chdk.setepontos.com/index.php?topic=11078.msg115942#msg115942 and https://chdk.setepontos.com/index.php?topic=12321.msg136200#msg136200 for example.

The "set" functions should be approached with caution, since they (presumably) manipulate undocumented hardware in an unspecified way. If you break anything, you get to keep both pieces ;)

As for how these relate to focus distance, my impression is that the position (or SD value for that matter) which actually gives optimal focus for objects at a given distance varies on a single camera between shooting sessions.
Don't forget what the H stands for.

Re: Lens movement/focus control
« Reply #2 on: 23 / January / 2023, 15:52:25 »
@reyalp


Thanks for the pointer.


I’m not interested in knowing distance.


My focus bracketing idea is only interested in knowing the steps from the current focus to infinity ;-)


I’ll explore a bit more and if th8ngs work out, report back here.


Cheers


Garry

*

Offline reyalp

  • ******
  • 14118
Re: Lens movement/focus control
« Reply #3 on: 23 / January / 2023, 16:30:45 »
My focus bracketing idea is only interested in knowing the steps from the current focus to infinity ;-)
Right, what I was trying to say is that for a given focal length on a single cam, the actual optimal focus for objects at a given distance (e.g. stars for "infinity") does not necessarily correspond to a single, fixed "position" value. Even if it is more or less repeatable on a given cam, it almost certainly is not across different cams of the same model.
Don't forget what the H stands for.


Re: Lens movement/focus control
« Reply #4 on: 23 / January / 2023, 16:49:11 »
Got it.


What I have done previously is calibrate the number of steps from the macro to when the Canon infinity is reached, and do this when the focal length changes.


What I need to confirm are the values of [size=78%]FocusSearchFar_FW, FocusSearchNear_FW and FocusPositionWithLensCom on the G5X, as a starter for my experiments. [/size]
[/size]
[/size][size=78%]Also, can I assume [/size][color=var(--color-prettylights-syntax-constant)][/size]call_event_proc[/color][/size]([/color][color=var(--color-prettylights-syntax-string)][/size]"EFLensCom.MoveFocus"[/color][/size], steps, [/color][color=var(--color-prettylights-syntax-constant)][/size]1[/color][/size]) will work on the G5X, ie as is?[/color]
[/size][/color]
[/size]Cheers[/color]
[/size][/color]
[/size]Garry[/color]

Re: Lens movement/focus control
« Reply #5 on: 23 / January / 2023, 16:50:12 »
Sorry, post got buggered up :-(

*

Offline c_joerg

  • *****
  • 1251
Re: Lens movement/focus control
« Reply #6 on: 24 / January / 2023, 01:36:27 »
My understanding was that functions like "EFLensCom.MoveFocus" are only available on the EOS M and not on the P&S.
« Last Edit: 24 / January / 2023, 01:38:41 by c_joerg »
M100 100a, M3 121a, G9x II (1.00c), 2*G1x (101a,100e), S110 (103a), SX50 (100c), SX230 (101a), S45,
Flickr https://www.flickr.com/photos/136329431@N06/albums
YouTube https://www.youtube.com/channel/UCrTH0tHy9OYTVDzWIvXEMlw/videos?shelf_id=0&view=0&sort=dd

Re: Lens movement/focus control
« Reply #7 on: 24 / January / 2023, 01:51:51 »
@c_joerg


Yes that was my recollection too :-(


Pity we don’t have access to moving the lens in steps on non-M powershots cameras, ie to use lens rotation.


That is, do focus stacking from the image side, not the object side of the lens.


Oh well, such is life.


Cheers


Garry


*

Offline reyalp

  • ******
  • 14118
Re: Lens movement/focus control
« Reply #8 on: 24 / January / 2023, 03:49:10 »
Sorry, post got buggered up :-(
You can switch off the WYSIWYG editor, either using the arrow in brackets icon at the right end of the toolbar, or off by default under profile -> look and layout. Then any formatting changes have to be done with forum codes in [ brackets ], which you can insert from the toolbar.

Quote
What I need to confirm are the values of FocusSearchFar_FW, FocusSearchNear_FW and FocusPositionWithLensCom on the G5X, as a starter for my experiments.

Also, can I assume call_event_proc("EFLensCom.MoveFocus") will work on the G5X, ie as is?
No, you should not assume that any of those functions exist or work on non-EOS cams. Lens control and communication on P&S is entirely different from EOS. I do not believe any of the ones you mentioned exist for G5X. call_event_proc will return -1 if the function is not registered.

You can look at the funcs_by_* csv files like https://app.assembla.com/spaces/chdk/subversion/source/HEAD/trunk/platform/g5x/sub/101d/funcs_by_name.csv to find likely candidates for equivalent functions. Not if you call by address (with call_func_ptr), you must use the csv that corresponds your specific camera and firmware version.

Of course, it's always a good idea to examine the firmware to figure out what arguments are expected before blindly calling a function, or ask someone here to have a look.
Don't forget what the H stands for.

Re: Lens movement/focus control
« Reply #9 on: 24 / January / 2023, 11:23:24 »
@reyalp

Many thanks for the reply.

Looking at the list of 'options', it's not that clear what will work, but the following seems interesting for my G5X 101d:

MoveFocusPosition_FW

Thus used in Lua as: call_event_proc("MoveFocusPosition_FW", n, m), where I'm guessing n is signed, ie direction, and m is speed? I'm basing this on a similar use in my M3, eg call_event_proc("EFLensCom.MoveFocus", -1, 1) works on my M3

Plus using 0xfc3b9fa1,GetCurrentFocusPosition_FW, ie as

GetCurrentFocusPosition_FW = 0xfc3b9fa1
j = call_func_ptr(GetCurrentFocusPosition_FW)

Hoping this returns the current focus step value

Using the above, assuming it is safe to do so, means I can

Find out the step value where I'm focused
Move to the macro end, ie move until the current step value is the same at the last one, and record the value
Move to infinity, ie until the current step value is the same as the last one, and record the value

Thus I know the lens full throw (MFD to infinity) in steps and can move by a specified number of steps using call_event_proc("MoveFocusPosition_FW", n, m), with n as the number of steps, eg 12 or -15, and m = 1, say

What do think?

Cheers

Garry
« Last Edit: 24 / January / 2023, 14:41:38 by pigeonhill »

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal