Setting focus from scripts or menus - page 58 - General Discussion and Assistance - CHDK Forum
supplierdeeply

Setting focus from scripts or menus

  • 601 Replies
  • 192872 Views
*

Offline reyalp

  • ******
  • 14082
Re: Setting focus from scripts or menus
« Reply #570 on: 05 / February / 2022, 16:44:00 »
Advertisements
as for creating a minimal script :)
i am good in math solutions, optimising and documenting existing systems, not in actual writing scripts.
What phil is asking for is the simplest script you can make that still shows the problem. This should not be advanced coding, there's only a handful of focus related functions, just call each one your script uses in order with hard coded values. You just need to understand what focus related values your script uses when you encounter the problem, and put those in a script that uses exactly those values instead of having a lot of options and complicated logic.

If you can't reproduce the problem that way (that is, your simple test script does correctly set focus), then you need to figure out what your real script is doing that's different.
Don't forget what the H stands for.

*

Offline Mlapse

  • *****
  • 583
  • S95 S110
Re: Setting focus from scripts or menus
« Reply #571 on: 05 / February / 2022, 18:09:12 »
although i will test caefix idea tomorrow I am not convinced the problem is in the script...i'm more and more convinced it's a problem of the G1X.

a simple script won't change these results:
prove me wrong: can you explain how a script that does nothing with focus and the cam is set in MF the same change of focus happens? (see log)
or why the results are also changing when using CHDK's "Override Subject Distance"? (see log)
both these methods have little or nothing to do with my script and can be repeated with any intervalometer script.

even without SUIx you get the same unpredictable results....at least on my g1X.

i just don't understand the logic of lua well enough to write from scratch unless it's a "hello world" script ;)
So the only way i know how to do this is by gutting the script function by function and testing if it still performs the interval and focus part until i have something lean.

i appreciate phil wanting to test some on his G1X.
then it can be confirmed or proven wrong what i see and log on my G1X.

but since you really want a lean script, i will try to finish that before the raccoons get out of their winter sleep :)



« Last Edit: 05 / February / 2022, 18:28:53 by Mlapse »
frustration is a key ingredient in progress

*

Offline reyalp

  • ******
  • 14082
Re: Setting focus from scripts or menus
« Reply #572 on: 05 / February / 2022, 21:09:22 »
although i will test caefix idea tomorrow I am not convinced the problem is in the script
FWIW, I frequently find caefix's posts and code difficult to understand, and to the extent I understand the code, it often seems convoluted, unrelated to the question at hand or just incorrect. I don't mean this to flame caefix, just a caution that you may not want to spend much time on it if what they post doesn't make sense to you.
Quote
prove me wrong: can you explain how a script that does nothing with focus and the cam is set in MF the same change of focus happens? (see log)
Which log, the one on this post? What specifically does it show?

If you want help, it's in your interest to explain, as clearly and simply as you can:

1) What specific steps you took
2) What specifically happened
3) How what happened differed from what you expected

A minimal script is a good way of accomplishing #1, but
Quote
or why the results are also changing when using CHDK's "Override Subject Distance"?
If  there is simple, step by step instruction to reproduce the problem using just menu options, that's fine too.

It sounds like your complaint is that subject distance reported by get_focus() changes between shots, in MF mode, regardless of CHDK overrides?

I've seen small changes after shooting, like setting the distance to the last step before INF and having it show INF after shooting. I've also seen it change on switching to play back. IMO, this is normal behavior, but I'm not clear if it is what you are talking about.

One other thing to note is that the specific get_focus values that result from a set_focus call are limited, and not consistent over time. For example, on my g7x, set_focus(170000) might result in a get_focus of 217323 or 195245, if it's 217323 on a given day, then setting 195245 is impossible (and vice versa).
Don't forget what the H stands for.

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Setting focus from scripts or menus
« Reply #573 on: 05 / February / 2022, 22:37:34 »
I've done some investigation of the values returned by the firmware for subject distance along with the values in the subject distance properties.
I've just used the camera manual focus, not CHDK overrides, to see how the camera behaves.


At closest focus distances the reported subject distance (both from lens_get_focus_pos() and SD properties) does not change even though a change can be seen in the viewfinder. For the four closest focus settings (using Canon MF) the reported SD is 275 even though the actual SD appears to change slightly.

At long focus distance the behaviour is not consistent. Focus at infinity reports SD of -1 as expected; but 1 step back from infinity reports different distances. Sometimes it will report a value of approx 28000, sometimes approx 33000, other times approx 45000.

I have also seen cases where the value returned by lens_get_focus_pos() changes with the camera just sitting still on the desk (after manually focussing).

I suspect this is a limitation / bug in the G1X.

CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)


*

Offline reyalp

  • ******
  • 14082
Re: Setting focus from scripts or menus
« Reply #574 on: 06 / February / 2022, 00:05:27 »
At long focus distance the behaviour is not consistent. Focus at infinity reports SD of -1 as expected; but 1 step back from infinity reports different distances. Sometimes it will report a value of approx 28000, sometimes approx 33000, other times approx 45000.
This is similar to what I see on G7 X and my SX7** cams. It's more obvious at the long end of the zoom. I don't recall ever seeing it change purely by itself, but I haven't spent much time looking for that either.

There's been previous discussion and investigation of functions that work with lens "position" functions rather than SD values. (my investigation https://chdk.setepontos.com/index.php?topic=11078.msg130083#msg130083, others https://chdk.setepontos.com/index.php?topic=12321.msg136202#msg136202 https://chdk.setepontos.com/index.php?topic=13935.0 )
My impression is the "position" values represent discrete commandable actuator values, and the calculated "subject distance" is based on some feedback from sensors in the optics, put through a formula to convert it to distance (which as noted in the last of those linked threads, blows up near infinity). That would explain varying "SD" values for a given "position", but it's just guesswork.
Don't forget what the H stands for.

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Setting focus from scripts or menus
« Reply #575 on: 06 / February / 2022, 00:26:29 »
There's been previous discussion and investigation of functions that work with lens "position" functions rather than SD values[size=78%].[/size]


I looked at the 'position' value being set/used during manual focus and I don't think it would help much.
Different reported SD values can have the same stepping motor 'position'.
E.G. at the wide end of the zoom:
SD -1 (Infinity) reported at positions 464, 465 and 466
Position 466 reported at SD -1, 45005 and 42034
Position 467 reported at SD 42753, 30534, 28968 and 21067
Position 468 reported at SD 28019, 19433, 16767 and 16166


These are just using Canon MF, no CHDK overrides.

CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline Mlapse

  • *****
  • 583
  • S95 S110
Re: Setting focus from scripts or menus
« Reply #576 on: 06 / February / 2022, 02:18:26 »
I looked at the 'position' value being set/used during manual focus and I don't think it would help much.
Different reported SD values can have the same stepping motor 'position'.
E.G. at the wide end of the zoom:
SD -1 (Infinity) reported at positions 464, 465 and 466
Position 466 reported at SD -1, 45005 and 42034
Position 467 reported at SD 42753, 30534, 28968 and 21067
Position 468 reported at SD 28019, 19433, 16767 and 16166

These are just using Canon MF, no CHDK overrides.

Thanks Phil :) , this looks like it is what i experience :( You just saved me a lot of time and possibly frustration.
So it's a problem with the G1X and possibly all that come after it, like the G7x.
although you only show 3 or 4 values per stepper motor position I've seen a lot more.
in the last log i posted I used manual focus and in one run of only 300 images you see values: 24497,22173,20400,18889,17583,16447,15449.
the only difference i see is that with MF you have a number that's running down or up in sequence with a few thousand inbetween.
and with set_aflock & set_focus i get numbers that jump up or down with each shot, sometimes with more than 20.000.

what i do think is strange is that you write it is the same stepper motor position.
i actually started investigating this because i had the distinct impression that there was a focus difference between shots when using set_focus.
i just saw confirmation in the numbers and didn't check the images anymore, but you write that the numbers don't matter in MF, because it is the same step of the motor.
I'll look into making some MF runs then to see if it turns up focus differences in the actual pictures like when i set it via CHDK. The same stepper motor position with each run would be workable for me. can i catch the stepper motor position in my log next to or instead of the get_focus calculation?
for now i inserted: call_event_proc('GetFocusLensCurrentPosition')

How did Einstein put it? In theory there is no difference between real life and theory. in real life there is .

« Last Edit: 06 / February / 2022, 07:49:10 by Mlapse »
frustration is a key ingredient in progress

*

Offline reyalp

  • ******
  • 14082
Re: Setting focus from scripts or menus
« Reply #577 on: 06 / February / 2022, 14:40:08 »
I looked at the 'position' value being set/used during manual focus and I don't think it would help much.
The advantages I can see is being able to access every distinct actuator position, and being able to move +/- 1 without dealing with the randomness in the distance to position conversion. I agree that won't solve mlapse issue, and probably would be minimally useful without implementing our own AF logic.

One of these days I do still want to try to implement a rawop based AF for astrophotography, since quite hard to get the best focus using the viewfinder.
Don't forget what the H stands for.


*

Offline Mlapse

  • *****
  • 583
  • S95 S110
Re: Setting focus from scripts or menus
« Reply #578 on: 06 / February / 2022, 15:26:02 »
i tried to look into the positions philmoz found of the focus steps and thought i could get those with:
call_event_proc('GetFocusLensCurrentPosition')
by setting it in MF but for some reason whatever i try it returns -1 :(
obviously, again :) i am wrong in something :)

phil, how do i go about catching those step position values in my log?
because i'm very interested in this.

and, second question, is there a key for the rear dial on the G1X, something i could use to test setting the focus 'manually', like click"wheel_left" (or right :) that would probably be very helpfull in creating some more tests.


if i can get the proper data i might be able to come up with something.

and reyalp, i was actually thinking that discrete steps of the motor would solve it for me, not only for astro photography. just use it with larger steps than you would.


« Last Edit: 06 / February / 2022, 15:38:05 by Mlapse »
frustration is a key ingredient in progress

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Setting focus from scripts or menus
« Reply #579 on: 06 / February / 2022, 16:18:20 »
i tried to look into the positions philmoz found of the focus steps and thought i could get those with:
call_event_proc('GetFocusLensCurrentPosition')
by setting it in MF but for some reason whatever i try it returns -1 :(
obviously, again :) i am wrong in something :)

phil, how do i go about catching those step position values in my log?
because i'm very interested in this.


You may need to call System.Create first - call_event_proc('System.Create')


Quote
and, second question, is there a key for the rear dial on the G1X, something i could use to test setting the focus 'manually', like click"wheel_left" (or right :) that would probably be very helpfull in creating some more tests.


I don't think there is any way to control the wheels or simulate wheel rotations from scripts.

CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

 

Related Topics