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

Setting focus from scripts or menus

  • 601 Replies
  • 190725 Views
Re: Setting focus from scripts or menus
« Reply #530 on: 25 / September / 2014, 15:45:06 »
Advertisements
For testing, I use iLua which provides at least basic syntax checking. BBEdit will also format scripts automatically with color-coding too, which I find helpful. In the end, the camera will give you a line number in the error messages, which helps to fix things,
There is a CHDK Lua simulator and environment (not exactly polished):
http://chdk.wikia.com/wiki/Lua_Development_Environment

Quote
though it's a pain to go back and forth.
I hope you are not trying to write anything non-trivial by swapping the SD card in & out of your camera?  With chdkptp and a USB cable you can download script revisions instantly.
« Last Edit: 25 / September / 2014, 18:01:21 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline eponymous

  • *
  • 38
  • Canon A4000
Re: Setting focus from scripts or menus
« Reply #531 on: 25 / September / 2014, 22:03:19 »
For testing, I use iLua which provides at least basic syntax checking. BBEdit will also format scripts automatically with color-coding too, which I find helpful. In the end, the camera will give you a line number in the error messages, which helps to fix things,
There is a CHDK Lua simulator and environment (not exactly polished):
http://chdk.wikia.com/wiki/Lua_Development_Environment

Quote
though it's a pain to go back and forth.
I hope you are not trying to write anything non-trivial by swapping the SD card in & out of your camera?  With chdkptp and a USB cable you can download script revisions instantly.

Excellent. I did not know what ptp was actually. (I assume I should have RTFM'ed.  :D)

I have installed Lua via homebrew, which gives me away as a mac user, so I can't run the hostlua development environment. I wonder though about using the emulator script. Any thoughts?

Also checking into running ptp on a Mac.
John

Re: Setting focus from scripts or menus
« Reply #532 on: 25 / September / 2014, 22:56:23 »
I have installed Lua via homebrew, which gives me away as a mac user, so I can't run the hostlua development environment. I wonder though about using the emulator script. Any thoughts?
I've used the emulator script successfully and it's good for at least a "first pass" run through your script for syntax and logic errors.  At some point though, to do anything useful, you really need a camera giving real-time data for your script to work on.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Setting focus from scripts or menus
« Reply #533 on: 29 / October / 2014, 21:04:59 »
GetFocusLensCurrentPosition has no arguments and is registered by Mecha.Create.
@srsa_4c : Is there an equivalent set of routines for VxWorks cameras ?
The predecessor of Mecha.Create is MechaRegisterEventProcedure, GetFocusLensCurrentPosition is available on all cameras. The s5is is the only DryOS model that doesn't know Mecha.Create .
I've been playing with this on & off for a couple of months now.  I have a really complicated script that requires taking pictures at various predefined subject distances & zoom setting and then records AF vs AFL vs MF readings and mecha position data.  So complicated that I have not tried it out on any of my seven CHDK equipped camera models.

Today I simplified it a lot (at least for now) and re-entered the pursuit.  See : Manual Focus @ Infinity not working for the script and instructions.

The first feedback from this suggests that the set_focus(65535) command may be running the mechanical lens position out past the position used by autofocus for infinity.  At least for some cameras and that would explain the "soft" images seen.   How we fix that is something to discuss once there is some more feedback from cameras that do not behave properly.



« Last Edit: 29 / October / 2014, 21:20:02 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16


Re: Setting focus from scripts or menus
« Reply #534 on: 07 / November / 2014, 20:28:24 »
In response to reyalp's post about moving 1.3.0 to stable and starting 1.4.0  ( here ) I've done quite a bit of thinking about SD override modes for menu, shortcut, & bracketing.

IIRC,  the options we have discussed end up looking like this :

  • Do nothing.  This will leave non-script SD overrides working for some cameras (those that will MF in AF mode),  not working for others,  and crashing completely for a few ( e.g. SX50hs)
  • Add low level interlocks to prevent cameras from attempting to MF when that action either will not work or will crash.  Safer but frustrating for a user when MF does not work for no apparent reason.
  • Option 2 but with an OSD message appearing to indicating MF is disabled when it is.
  • Option 3 with the addition of a Subject Distance Override menu that let's users do the right things to get SD overrides to work. My choice FWIW- see below.
  • Attempt to make all SD override "just work".  Tough one to get right. For example, do you enable/disable AFL or MF before/after each shot?  AFL enabling causes a focus and exposure reading sort of like a half press.   And does spytask (for example) monitor the requested state vs the actual state and take corrective actions if they don't match.  It gets complicated really quickly!

Here's a couple of screen shots of what I think is needed for option four :



The first two menu items do what you expect. They could be combined into one (maybe - have not worked through all the use cases yet).  I'd add hypf ( for hyperfocal distance) to the options in the second line.

The third and fourth menu items get moved here from the OSD Settings DOF Calculator,  where they currently don't really belong but are there anyway.

The fifth and sixth menu items  ( AFL and MF ) are toggles.  Press Func/Set and they invert the current AFL or MF state of the camera and show a dialog box confirming what just happened.   If one mode is enabled,  the other should probably be disabled automatically? 

Also, when you exit this menu,  you get a warning message if you have requested an override and the current camera mode ( AFL, MF, AF) won't support it.

If this seems like a reasonable approach,  I'll finish up the patch file and submit for testing.  Comments?

Update : lots of details to work out here.  For example, toggling AFL or MF are immediate changes - so you'll get an error message if you try to do it in playback mode.  And they only "stick" until the camera powers off.  Might want to move SD bracketing menu options here too?  I'm sure there are a few dozen other "gotcha's" but this is the simplest useful change I can come up with.
« Last Edit: 07 / November / 2014, 20:40:01 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Setting focus from scripts or menus
« Reply #535 on: 07 / November / 2014, 20:43:18 »
Looks ok except, as you said, the first entry is probably redundant.

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)

*

Offline reyalp

  • ******
  • 14079
Re: Setting focus from scripts or menus
« Reply #536 on: 09 / November / 2014, 18:48:35 »
Option 3 with the addition of a Subject Distance Override menu that let's users do the right things to get SD overrides to work. My choice FWIW- see below.
I agree, this seems like the best option.
Quote
The fifth and sixth menu items  ( AFL and MF ) are toggles.  Press Func/Set and they invert the current AFL or MF state of the camera and show a dialog box confirming what just happened.   If one mode is enabled,  the other should probably be disabled automatically? 

Also, when you exit this menu,  you get a warning message if you have requested an override and the current camera mode ( AFL, MF, AF) won't support it.
The UI for these seems pretty awkward.

Ideally, ignoring what we can actually do in the menus I'd want enum (or equivalent radio button) like
Code: [Select]
Override focus mode: [ none | MF | AF Lock]
with some indication it takes immediate effect, and also an indication if it's disable because you are in play or something.

This seems like it would be hard to do in CHDK menu code. An alternative would be to have one menu item
"Override focus mode..."

Which brings up a dialog box like
Code: [Select]
Select focus override mode
Current mode is ...
This takes effect immediately
[none] [MF] [AF Lock] [Cancel]
Or if you are in play, just gives you and error.

edit
Quote
And they only "stick" until the camera powers off.
Probably not even that, I would expect switching to play and back to clear them, and display off (using the button or from power save) or zoom changes may on some cameras.

Another question is how reliably we can know the current state. For AF lock, we override the property case, but it's possible that something like switching to play would clear the actual AF lock without clearing the prop case, or vice versa.
« Last Edit: 09 / November / 2014, 19:00:12 by reyalp »
Don't forget what the H stands for.

Re: Setting focus from scripts or menus
« Reply #537 on: 09 / November / 2014, 19:24:14 »
The UI for these seems pretty awkward.
I'd prefer to call it simplistic.

Quote
Ideally, ignoring what we can actually do in the menus I'd want enum (or equivalent radio button) like
Code: [Select]
Override focus mode: [ none | MF | AF Lock]
with some indication it takes immediate effect, and also an indication if it's disable because you are in play or something.
This seems like it would be hard to do in CHDK menu code. An alternative would be to have one menu item
"Override focus mode..." Which brings up a dialog box like
Code: [Select]
Select focus override mode
Current mode is ...
This takes effect immediately
[none] [MF] [AF Lock] [Cancel]
Or if you are in play, just gives you and error.
I don't disagree with all this but per, your following comments, we are pretty limited in what this actually does.  So I was shooting for the equivalent of enabling AFL from the Canon mode dial - nothing fancier - and allowing the MF equivalent of the same thing.   The concern I have with the dialog selection box is that it could easily be mistaken for a setting that will stick - select this once and CHDK will lock your camera in that mode forever. 

And franky,  despite six plus months of work I don't know how well even this will work.  But at least it give the user a shot at doing the same thing a script can do - albeit in a primitive mode.

Quote
Quote
And they only "stick" until the camera powers off.
Probably not even that, I would expect switching to play and back to clear them, and display off (using the button or from power save) or zoom changes may on some cameras.
Another question is how reliably we can know the current state. For AF lock, we override the property case, but it's possible that something like switching to play would clear the actual AF lock without clearing the prop case, or vice versa.
Hence my suggested crude and simplistic implementation.  Something that can get done so we can close out 1.3.0 and at least gives an easily explained result.  Somebody else can tackle "fancy" and "flexible" and "just works in every circumstance" in 1.4.0
« Last Edit: 09 / November / 2014, 19:28:45 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16


Re: Setting focus from scripts or menus
« Reply #538 on: 16 / November / 2014, 17:41:10 »
Really don't know if these findings could help in some way to solve the mistery of setting focus via scripts not working properly on few camera.

Playing a bit with set focus and video scripts i noticed that a set_aflock(1) command resets exposure on my ixus115 even if a set_aelock(1) was previously called.
Also, the new/updated exposure values will stay locked after a set_aflock(1) or a set_focus(x) command has been applyed in the video script.
The ixus115 does SD override pretty well.

The same thing doesn't occur on the ixus125 where the exposure values aren't altered after a set focus command.
The ixus125 doesn't SD override pretty well.

Are set focus commands related to exposure / scene brightness with a different behaviour for camera that don't override SD properly (s100, ixus125, ...) ?

This my 4 months old post, when testing focus scripts on ixus125, seems to confirm the relationship.

Re: Setting focus from scripts or menus
« Reply #539 on: 07 / February / 2015, 17:30:23 »
hello
Does "MF_test.lua" work with "ixus 240"?
or is any focus script for ixus 240?
thanks

 

Related Topics