set_zoom problems in uBASIC & Lua scripts - page 7 - General Discussion and Assistance - CHDK Forum  

set_zoom problems in uBASIC & Lua scripts

  • 91 Replies
  • 47958 Views
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #60 on: 22 / March / 2014, 18:44:22 »
Advertisements
Thanks for the reply.  I have servo AF "off" and AF Beam Assist "off" and AF Point Zoom "off".   I didn't see an option for continuous AF

Re: set_zoom problems in uBASIC & Lua scripts
« Reply #61 on: 30 / September / 2014, 09:03:10 »
My A1400 crashes regularly, if i use set_zoom with big zoom changes.

set_zoom(0);set_zoom(1);set_zoom(2);set_zoom(3);set_zoom(4);set_zoom(5);set_zoom(6);
works

set_zoom(0);set_zoom(6);
crash every time.


Re: set_zoom problems in uBASIC & Lua scripts
« Reply #62 on: 30 / September / 2014, 09:42:59 »
My A1400 crashes regularly, if i use set_zoom with big zoom changes.

set_zoom(0);set_zoom(1);set_zoom(2);set_zoom(3);set_zoom(4);set_zoom(5);set_zoom(6);
works

set_zoom(0);set_zoom(6);
crash every time.
What happens if you insert a sleep(2000) after each set_zoom() command? I've also seen things stabilize if you do a "shoot_half" sequence between each set_zoom - giving the camera a chance to refocus.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline srsa_4c

  • ******
  • 4451
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #63 on: 13 / October / 2019, 12:54:33 »
Apologies for digging this up, but I have a question.

Is there a specific reason for adjusting focus in the CHDK routines behind set_zoom? That seems to be the cause of crashes on lots of cameras. Couldn't we just make re-focusing optional somehow?


*

Offline reyalp

  • ******
  • 14121
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #64 on: 13 / October / 2019, 14:28:30 »
Is there a specific reason for adjusting focus in the CHDK routines behind set_zoom? That seems to be the cause of crashes on lots of cameras. Couldn't we just make re-focusing optional somehow?
That's a good question. I think it's just because setting zoom loses focus, so a refocus of some kind would generally be needed anyway. This feature is from a time when there were only a few cameras which didn't have the range of behavior and different modes that modern ones do.

* If the camera is in regular AF mode, focus will be updated on the next half press. This means the current behavior is mostly just trying to start the live view at the right distance.
* If it's in MF or AFLock, then it would need to be reset manually.
* In continuous AF, it should update immediately, and the current CHDK code should have skipped the refocus anyway (+/- the video mode issue)
* Servo and tracking AF should only apply in half press, when zoom change is not possible (AFAIK) We currently skip resetting in servo.
* Video recording would generally want focus updated ASAP, or ideally kept as the zoom happens.

Some existing scripts probably expect the current behavior, which might argue for keeping it as the default, or dependent on @chdk_version
Don't forget what the H stands for.

*

Offline srsa_4c

  • ******
  • 4451
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #65 on: 13 / October / 2019, 15:35:02 »
Some existing scripts probably expect the current behavior, which might argue for keeping it as the default, or dependent on @chdk_version
Adding a menu option with the non-crashing behaviour as default? (Problematic camera -> no refocus). That would let those cameras run set_zoom'ing scripts without crashing, at the expense of possibly incorrect focus after zoom.

Oh, and a related but different issue: the incorrect distortion when not using CAM_USE_ALT_PT_MoveOpticalZoomAt. I suspect that almost all D4 and later cameras need the alternative zooming method as distortion correction and distorting lens designs were introduced in DIGIC 4 cams.

*

Offline reyalp

  • ******
  • 14121
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #66 on: 13 / October / 2019, 18:02:30 »
Adding a menu option with the non-crashing behaviour as default? (Problematic camera -> no refocus). That would let those cameras run set_zoom'ing scripts without crashing, at the expense of possibly incorrect focus after zoom.
My initial reaction was set_zoom only affects script and USB remote, so maybe the control should be in script, but thinking more, menu gives users an option to have the old behavior without modifying their script.

OTOH, if someone writes a script that does need to restore focus after changing zoom, they either have to override the menu option, or re-implement the logic in script. Logic implemented by one person for a script is likely to be less portable and widely tested than the built in logic.
Another approach would be
set_zoom(step, do_refocus)
where do_refocus defaults to either false, or the menu option if both are implemented. This would let scripts that actually need to preserve focus use the built in logic. They would still crash on problem cameras, but if the script actually needs it, the same logic in script would likely crash too.

I'm just thinking out loud (and maybe overthinking) at this point.

Quote
Oh, and a related but different issue: the incorrect distortion when not using CAM_USE_ALT_PT_MoveOpticalZoomAt. I suspect that almost all D4 and later cameras need the alternative zooming method as distortion correction and distorting lens designs were introduced in DIGIC 4 cams.
I think this is correct. IIRC D10 was an exception (D4 cam that doesn't need) but the vast majority should have it.

I seem to recall some discussion whether it gives distortion correction equivalent to the using the physical controls.

edit:
I noticed modern cameras (~ixus160 and later) have UIFS_MoveZoomToPositionWithTaskSwCtrlServ_FW, which kind of suggests a higher level function. It appears to take 3 parameters
« Last Edit: 13 / October / 2019, 18:28:23 by reyalp »
Don't forget what the H stands for.

*

Offline srsa_4c

  • ******
  • 4451
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #67 on: 14 / October / 2019, 11:50:48 »
I noticed modern cameras (~ixus160 and later) have UIFS_MoveZoomToPositionWithTaskSwCtrlServ_FW, which kind of suggests a higher level function. It appears to take 3 parameters
That's a nice find. It could simplify this whole discussion. This eventproc also shows how to pass a function to CtrlSrv for execution.
Internally, it appears to use a function which is also available as eventproc UIFS_MoveZoomTo (all DryOS cams, except S5IS). Takes 3 params, first is zoom point (optical+digital), second is speed, third is an optional callback function.
Tried on two cams so far. No crashes, even during video recording. Displays the native zoom bar on screen. Also seems to maintain focus(!). Minor issue is that it resets any previously set digital zoom.


*

Offline reyalp

  • ******
  • 14121
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #68 on: 14 / October / 2019, 17:15:13 »
Internally, it appears to use a function which is also available as eventproc UIFS_MoveZoomTo (all DryOS cams, except S5IS). Takes 3 params, first is zoom point (optical+digital), second is speed, third is an optional callback function.
Tried on two cams so far. No crashes, even during video recording. Displays the native zoom bar on screen. Also seems to maintain focus(!). Minor issue is that it resets any previously set digital zoom.
Nice  :D The digital zoom stuff under CAM_USE_ALT_SET_ZOOM_POINT might be helpful if you wanted to workaround that. Interaction with "Digital teleconverter" setting should also be checked (Digital zoom mode = 1.6x / 2x on newer cams)

Speed is interesting too. The existing set_zoom_speed only works on a few cameras, _SetZoomActuatorSpeedPercent is nullsub on most.

Don't forget what the H stands for.

Re: set_zoom problems in uBASIC & Lua scripts
« Reply #69 on: 15 / October / 2019, 07:27:08 »
Watching, as a (G1X and G7X) scripter who is always looking for a 'better' way of dialling in an 'accurate' focus distance, ie after I've calculated where to move to from where I am  ;)

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal