AF control

Started by garry23, March 24, 2018, 09:59:54 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

garry23

Hope someone can help. Using Lua, is it possible to control, ie switch on and off, AF?

a1ex

If you take pictures using camera.shoot, there is a parameter that can optionally enable autofocus for that picture.

ML does that by temporarily moving the AF to the back button (to disable AF) and to half-shutter (to enable AF). That seems to work well for pictures triggered from ML (the remote capture routine called by ML - call("Release") - autofocuses if AF is enabled AND on half-shutter).

Changing PROP_AF_MODE doesn't seem to work (that would have overridden the physical switch on the lens - if it worked).

Toggling between AF on half-shutter and on back button can be done (ML has a function for that), but I'm not sure it's a good idea to change this setting globally (it's a persistent setting from Canon menu, so the user doesn't expect it to be changed by some unrelated function). There are already lots of reports of this setting being changed in a way not expected by the user (happens if you take the battery out in the middle of a long exposure, for example; in this case, ML is not able to restore the old setting at shutdown).

There is also lens.autofocus(), which performs just the autofocus step, should you need it for something else (other than taking a picture with camera.shoot()).

garry23

@a1ex

Thanks for the reply.

As you imply, I've played around with some of the things you mentioned, but it doesn't deal with what I'm trying to solve.

My use case is that I'm using long halfshutter events, say, 3sec, to trigger my scripts.

The trouble is, if AF is enabled, sometimes, if I'm not careful with my (back button) AF use, the AF event triggers my script.

A work around is that I increase my script's trigger time to, say, 5+ secs, 'hoping' no true AF event will take long than this.

What I was thinking of doing, if I could switch off AF, was to have the script able to switch off AF, and back on after its use.

Cheers

Garry

a1ex

Got it. I can add a Lua function to switch the AF between back button and half-shutter, but I need a suggestion for its name.

garry23

@a1ex

Great   :)

I assume you will wish it to be in the Lua lens module.

Of course, you will know the naming protocol better than me.

There is an autofocus function, which I guess could be extended to carry out a set operation, eg

lens.autofocus(true/false,[trigger_mode = back or half-shutter]) thus lens.autofocus(true) would autofocus as now. Lens.autofocus(true, back or half-shutter) likewise would autofocus as now.

Lens.autofocus(false,back) would simply switch the AF to the back button and lens.autofocus(false,half-shutter) would switch the AF to the half-shutter.

Cheers

Garry

a1ex

I'd like not to overload lens.autofocus() with different functionality. One performs the autofocus process (it moves the lens), the other changes some setting.

I could say lens.af = true or false, but what it actually does, is slightly different. Disabling AF is only for pictures triggered by ML and for half-shutter, but AF is still enabled on the back button. So I'd still like a name that matches what the function is going to do...

garry23

Ok, how about lens.af_trigger(back or half-shutter) or lens.af_trigger_mode(...