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

Setting focus from scripts or menus

  • 601 Replies
  • 192879 Views
*

Offline Mlapse

  • *****
  • 583
  • S95 S110
Re: Setting focus from scripts or menus
« Reply #560 on: 04 / February / 2022, 16:10:44 »
Advertisements
was wondering if it would make a difference, and the first i see if i exchange the if statement as you suggested is that i do not see AFL anymore if the cam is started in AF and the script is started.
well, it does change something :)
tomorrow i'll have a log to check.
frustration is a key ingredient in progress

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Setting focus from scripts or menus
« Reply #561 on: 04 / February / 2022, 19:20:18 »
i am testing set focus on the G1X in Av mode, but it doesn't seem to work as I expected.


If you can post a minimal script that demonstrates the problem I can investigate on my 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 Mlapse

  • *****
  • 583
  • S95 S110
Re: Setting focus from scripts or menus
« Reply #562 on: 05 / February / 2022, 04:10:32 »
alas, swapping out mf and afl did not solve the focus issue, but it was a good try.
may lead to me to implement some more of these suggestions for tackling different models:
https://chdk.fandom.com/wiki/CHDK_Manual_Focus_and_Subject_Distance_Overrides

as for creating a minimal script :)
i am good in math solutions, optimising and documenting existing systems, not in actual writing scripts.
the only reason i made the shoot function was because CHDK is missing automatic longer than 1 sec. exposure.

maybe this helps, so sorry for all the clutter of this more-than-minimal script.
I've uploaded a slightly modified script that logs get focus after each shot.
load it, set focus @ infinity to true, start the script by pressing the shutter button and look at the log and/or images after at least 20 shots..it is also influenced by light changes i think.
'SUIx latest version'

this log is from my last test where the cam was set in MF on the cam and saved. and focus @ infinity was false in script. (safety MF is off in canon menu)
the cam was shut down and restarted before the script was started.
since the script did not interfere in focus on this run it looks like a cam/setting issue.
started the cam and script twice to see if i could get same results :(
« Last Edit: 05 / February / 2022, 06:53:02 by Mlapse »
frustration is a key ingredient in progress

*

Offline Caefix

  • *****
  • 945
  • Sorry, busy deleting test shots...
Re: Setting focus from scripts or menus
« Reply #563 on: 05 / February / 2022, 11:43:14 »
alas, swapping out mf and afl did not solve the focus issue, but it was a good try.
... and focus @ infinity was false in script.  :haha

Code: [Select]
--Header:
# focus_at_infinity  false "Focus @ Infinity?"
# conf140            false "subj_dist_override_value"
--
fixed_focus = false -- global value

function lock_focus(distance)
    if fixed_focus == true then return end
    distance=distance or 0
    if focus_at_infinity then distance = -1
    elseif conf140 then distance=get_config_value(140) end

    local sd_modes = get_sd_over_modes()                            -- get camera's available MF modes - use AFL if possible, else MF if available
    if ( bitand(sd_modes, 0x02) ~= 0 ) then
        set_aflock(true)
    end
    if ( bitand(sd_modes, 0x04) ~= 0 ) then
        set_mf(true)
        if (get_prop(props.FOCUS_MODE) ~= 1) then printf("Warning:MF enable failed***") end
    end
    if ( sd_modes ~= 0  and distance ~=0) then
        sleep(1000)
        set_focus(distance)
        sleep(1000)
        fixed_focus = true
    end
end

function unlock_focus()
 --   if (focus_at_infinity) then                                         -- focus lock at infinity requested ?
    if fixed_focus == false then return end
    local sd_modes = get_sd_over_modes()                            -- get camera's available MF modes
    if ( bitand(sd_modes, 0x02) ~=0 ) then
        set_aflock(false)
    end
    if ( bitand(sd_modes, 0x04) ~= 0 ) then
        set_mf(false)
    end
    fixed_focus = false
 --   end
end

focus_at_infinity seems the only condition to call function lock_focus...
Now You could define a #distance in header or from AF...
How about a MacroSUIx ? ::)
« Last Edit: 05 / February / 2022, 14:49:04 by Caefix »
All lifetime is a loan from eternity.


*

Offline Mlapse

  • *****
  • 583
  • S95 S110
Re: Setting focus from scripts or menus
« Reply #564 on: 05 / February / 2022, 12:14:57 »
focus_at_infinity seems the only condition to call function lock_focus...
Now You could define a #distance in header or from AF...
How about a MacroSUIx ? ::)

i have no idea how i could define that differently than it is now, if you have suggestions how to do that,  i'll try it.
setting focus at -1 is not what i'm looking for, that solution only works well on 1/1.7 and smaller sensors. with the g1x it sets focus too far away for my purpose due to the large sensor
and -1 is the default if you start a cam without setting focus, so no need to include it in a script.
as far as i can see -1 is also not a fixed position.
i would be happy with any value ranging from 25-50 meter (set_focus at 25000-50000) as long as it's repeatable after a new start or reboot.

and a macro setting? in what way would that help in solving the not reliable focus of the G1X?

further test with the CHDK setting "Override Subject Distance" revealed that it would also not set correctly or hold the focus between shots.

another log:
first run MF without CHDK override(focus as saved in canon menu and used in earlyer log), next 2: MF with CHDK override active.(set at 49500) (focus @ infinity in script = false)
if it's important i can rerun it with AF settings.
« Last Edit: 05 / February / 2022, 13:13:46 by Mlapse »
frustration is a key ingredient in progress

*

Offline Caefix

  • *****
  • 945
  • Sorry, busy deleting test shots...
Re: Setting focus from scripts or menus
« Reply #565 on: 05 / February / 2022, 13:37:24 »

setting focus at -1 is not what i'm looking for, that solution only works well on 1/1.7 and smaller sensors.
as far as i can see -1 is also not a fixed position.
Wide angle default?
Quote
another log: next 2: MF with CHDK override active.(set at 49500) (focus @ infinity in script = false)

Probably need to pick ...
Code: [Select]
core/conf.c
    CONF_INFO(140, conf.subj_dist_override_value,               CONF_DEF_VALUE, i:0),

... then lock_focus(get_config_value(140)) end :)
« Last Edit: 05 / February / 2022, 13:39:31 by Caefix »
All lifetime is a loan from eternity.

*

Offline Mlapse

  • *****
  • 583
  • S95 S110
Re: Setting focus from scripts or menus
« Reply #566 on: 05 / February / 2022, 13:44:22 »
in assuming you meant set_aflock(1) set_focus(get_config_value(140))
don't think setting it twice will solve it, but i'll test anyway tomorrow.

as for -1, no i do not think it's a wide angle setting, it's just the position the focus ends when the lens is extended and still has an undefined location..and for some reason that's not always the same position.
« Last Edit: 05 / February / 2022, 13:57:39 by Mlapse »
frustration is a key ingredient in progress

*

Offline Caefix

  • *****
  • 945
  • Sorry, busy deleting test shots...
Re: Setting focus from scripts or menus
« Reply #567 on: 05 / February / 2022, 14:04:12 »
in assuming you meant set_aflock(1) set_focus(get_config_value(140))
no, I meant the code in the upper window,
https://chdk.setepontos.com/index.php?topic=11078.msg147720#msg147720  with...
... then lock_focus(get_config_value(140)) end :)
where You need it.
All lifetime is a loan from eternity.


*

Offline Mlapse

  • *****
  • 583
  • S95 S110
Re: Setting focus from scripts or menus
« Reply #568 on: 05 / February / 2022, 14:14:07 »
to me that sounds the same, but will do it your way :)
frustration is a key ingredient in progress

*

Offline Caefix

  • *****
  • 945
  • Sorry, busy deleting test shots...
Re: Setting focus from scripts or menus
« Reply #569 on: 05 / February / 2022, 16:08:00 »
i would be happy with any value ranging from 25-50 meter (set_focus at 25000-50000) as long as it's repeatable after a new start or reboot.
:D...
Code: [Select]
@title coSUIx

press ("shoot_half")
sleep(3000)
if get_focus_state() ~=0 then set_config_value(140, get_focus())
   play_sound(0) end
release ("shoot_half")
All lifetime is a loan from eternity.

 

Related Topics