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

Setting focus from scripts or menus

  • 601 Replies
  • 154378 Views
Re: Setting focus from scripts or menus
« Reply #360 on: 14 / March / 2014, 09:09:21 »
Advertisements
http://chdk.setepontos.com/index.php?topic=11078.msg110934#msg110934

For the S110,  the set_aflock() command is currently disabled.  If you can run the test requested there and the camera passes,  we can have it re-enabled.  (If the test crashes with shoot() enabled, please disable it from the script parameter menu and rerun the test?)
Done and it seems to pass - see attachment.

Also,  with the version of CHDK you are running now, you can use the set_mf(1) command in the place of set_aflock(1) to enable manual focus.  (Do not set the propcase in your code.)
I will try it, but I prefer the AF lock :)

Re: Setting focus from scripts or menus
« Reply #361 on: 14 / March / 2014, 09:25:01 »
I will try it, but I prefer the AF lock :)
I think most people will agree with that.   Once we figure out how to stop crashing if two shots are too close together,  I think it will become the default method for almost all cameras.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 13675
Re: Setting focus from scripts or menus
« Reply #362 on: 14 / March / 2014, 22:26:55 »
Would the call to shooting_can_focus() fail the set_focus() function immediately or would it wait (with a timeout) for a bit to allow the previous shot to finish ?  (realizing that if it's saving CHDK RAW that could be several seconds).
I think my preference to be to fail immediately. Scripts that want to wait can do it themselves.

It's not optimal to have set_focus fail under poorly specified conditions, but it's better than crashing.
Don't forget what the H stands for.

*

Offline philmoz

  • *****
  • 3407
    • Photos
Re: Setting focus from scripts or menus
« Reply #363 on: 15 / March / 2014, 18:40:10 »
Attached below is a little script that enables AFL and then shoots two shots close together with an optional set_focus() between them.  It also optionally lets you insert a two second delay between the shots and/or wait for get_shooting() to be true between the shots.

On my SX50,  if both the delay and get_shooting() wait are disabled and the set_focus() is enabled, the camera crashes with an ASSERT!! FocusLensController.c .  If either the delay or get_shooting() are enabled, or the set_focus is disabled, there is no crash.

I'd be interested to hear results from anyone else.

NOTE: my other cameras don't crash regardless of the parameter choices.

Tested on G12, G1X and SX40. No crashes; but other strangeness (haven't had time to investigate yet).

G12 & G1X - if 'with delay' and 'with get_shooting' are both 'No' then only the first shot is taken. The second shot does not happen, although the set_focus is done and the focus position is updated.

SX40
 - set_afl works correctly.
 - If I use set_mf then the first set_focus does nothing unless there is a delay after the set_mf call (1 sec delay works, 0.5 second delay doesn't).
 - The final call to set_mf(0) does not work, the camera remains in MF mode.

On the SX40 the call to set_mf(1) changes the camera to MF mode in the Canon OSD. Neither the G12 or G1X do this even though they have native MF mode.

Phil.
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)


Re: Setting focus from scripts or menus
« Reply #364 on: 15 / March / 2014, 18:48:07 »
Tested on G12, G1X and SX40. No crashes; but other strangeness (haven't had time to investigate yet).

G12 & G1X - if 'with delay' and 'with get_shooting' are both 'No' then only the first shot is taken. The second shot does not happen, although the set_focus is done and the focus position is updated.
Thanks for taking a look.

Delay timing seems to be fussy on some (most?) cameras.  What happens if you increase the delay between the first and second shot?

Quote
SX40
 - set_afl works correctly.
 - If I use set_mf then the first set_focus does nothing unless there is a delay after the set_mf call (1 sec delay works, 0.5 second delay doesn't).
 - The final call to set_mf(0) does not work, the camera remains in MF mode.
Does it need an extra delay too?

Quote
On the SX40 the call to set_mf(1) changes the camera to MF mode in the Canon OSD. Neither the G12 or G1X do this even though they have native MF mode.
FWIW, the SX40 calls PostLogicalEventForNotPowerType(levent_id_for_name("PressSw1AndMF"),0).  The G12 and G1X call _PT_MFOn() directly.
 
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 13675
Re: Setting focus from scripts or menus
« Reply #365 on: 15 / March / 2014, 18:52:50 »
Quote
On the SX40 the call to set_mf(1) changes the camera to MF mode in the Canon OSD. Neither the G12 or G1X do this even though they have native MF mode.
FWIW, the SX40 calls PostLogicalEventForNotPowerType(levent_id_for_name("PressSw1AndMF"),0).  The G12 and G1X call _PT_MFOn() directly.
This may explain some of the delay behavior.
I've noticed on my cameras *MFOn take a noticeable amount of time to execute, so they probably block until the camera is actually in MF mode. PostLogicalEvent* most likely just sends the event off for some other task to process and returns quickly. It's possible that waiting for the MF propcase to update would be the right thing to do for this situation.

This should be testable on cameras that don't require the PostLogicalEvent* method.
Don't forget what the H stands for.

*

Offline philmoz

  • *****
  • 3407
    • Photos
Re: Setting focus from scripts or menus
« Reply #366 on: 15 / March / 2014, 18:57:43 »
Tested on G12, G1X and SX40. No crashes; but other strangeness (haven't had time to investigate yet).

G12 & G1X - if 'with delay' and 'with get_shooting' are both 'No' then only the first shot is taken. The second shot does not happen, although the set_focus is done and the focus position is updated.
Thanks for taking a look.

Delay timing seems to be fussy on some (most?) cameras.  What happens if you increase the delay between the first and second shot?

With both options set to 'no' there is no delay between the shots - it looks like get_shooting() remains true for a while after the 1st shot, and the 2nd shot code goes straight through with the half_press/full_press being ignored.

Quote
Quote
SX40
 - set_afl works correctly.
 - If I use set_mf then the first set_focus does nothing unless there is a delay after the set_mf call (1 sec delay works, 0.5 second delay doesn't).
 - The final call to set_mf(0) does not work, the camera remains in MF mode.
Does it need an extra delay too?

Don't think so - it's the last thing called before the script finishes. Unless it's somehow not being called at all I can't see how an extra delay here would help. Need to do some more testing.

Quote
Quote
On the SX40 the call to set_mf(1) changes the camera to MF mode in the Canon OSD. Neither the G12 or G1X do this even though they have native MF mode.
FWIW, the SX40 calls PostLogicalEventForNotPowerType(levent_id_for_name("PressSw1AndMF"),0).  The G12 and G1X call _PT_MFOn() directly.

Thanks, I haven't followed the developments with the MF changes closely. Will do some more investigation when I get a chance.

Phil.
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)

Re: Setting focus from scripts or menus
« Reply #367 on: 15 / March / 2014, 19:14:13 »
- The final call to set_mf(0) does not work, the camera remains in MF mode.
Quote
Does it need an extra delay too?
Don't think so - it's the last thing called before the script finishes. Unless it's somehow not being called at all I can't see how an extra delay here would help. Need to do some more testing.
As mentioned,  the SX40 uses "PressSw1AndMF" - which AFAIK is a toggle function (at least it is on my cameras) so if it's not turning MF off its kind of strange.

Quote
Thanks, I haven't followed the developments with the MF changes closely.
Somedays I wish I could say the same.   ???
Ported :   A1200    SD940   G10    Powershot N    G16


*

Offline reyalp

  • ******
  • 13675
Re: Setting focus from scripts or menus
« Reply #368 on: 15 / March / 2014, 19:24:20 »
I tested elph130. The af_lock method works as expected only takes one shot.

set_mf without delay only takes one shot.

The output does not show the focus updated, like
Shot 1 focus= 500  : 2846
Shot 2 focus= 3000 : 494

which is probably due to the issue mentioned in : http://chdk.setepontos.com/index.php?topic=11078.msg110967#msg110967 since the camera doesn't have native MF, the actual focus update happens in shooting.

With get_shooting set, the output is still wrong, but both shots are taken and the focus appears to be adjusted in the images.

With the patch applied, output is correct but no wait still only takes one shot. get_shooting() mode appears to work correctly.

edit:
I went back and retested the other cams, since I wasn't certain I actually verified that two shots were taken before.
D10 works correctly in both mf and aflock (sets focus, takes two shots) if it is in continuous mode. In regular mode, it only takes one shot. Or possibly it's somewhat random.

A540 appears to work correctly in either mode, without get_shooting and not in continuous mode.

The elph130 was in continuous mode.

I had raw disabled on all to avoid additional delay.

I think phil is right about the 1 shot behavior being script logic rather than specific to the set_focus stuff. To test whether focus can be updated inside get_shooting, it would probably be better to set the focus immediately, and then wait for get_shooting before trying to actually shoot again.

edit:
note the patch linked above isn't completely correct, it will be confused by modes other than regular AF. I'm not sure I understand the logic in shooting_get_real_focus_mode() - actual it was right, see below.
« Last Edit: 15 / March / 2014, 22:27:42 by reyalp »
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 13675
Re: Setting focus from scripts or menus
« Reply #369 on: 15 / March / 2014, 21:27:12 »
To sort out shooting_get_real_focus_mode() (which is used for the script function get_focus_mode  I made the attached spreadsheet.

The was obtained using
Code: [Select]
!status,s=con:execwait([[p=require'propcase' return string.format("%d,%d,%d,%d",get_focus_mode(),get_prop(p.FOCUS_MODE),get_prop(p.REAL_FOCUS_MODE),get_prop(p.AF_LOCK))]]) print(s)
(all one line)
in chdkptp. Canon modes were set manually in the camera UI.

A few notes:

We listed PressSw1AndMF as "working" for D10 in waterwingz spreadsheet, but it actually has no effect. Since the camera is able to override in AF, overrides continue to work after calling it. Elph130 is similar: override crashes in AF and also crashes with PressSw1AndMF.

get_focus_mode essentially returns propcase REAL_FOCUS_MODE with the MF and Macro values swapped. I assume the reason for this is historical, at one point it probably just returned 0=auto 1=mf.

set_mf overrides the FOCUS_MODE propcase, but does not override REAL_FOCUS_MODE. It should possibly set it to 4 when set_mf is used, but what value to restore it to would not necessarily be clear. Manually setting this to 4 does NOT show the Canon MF UI on D10 when using set_mf.
Don't forget what the H stands for.

 

Related Topics