Focusser - a script for running linear or exponential focus variations - Script Writing - CHDK Forum

Focusser - a script for running linear or exponential focus variations

  • 11 Replies
  • 5145 Views
Advertisements
focusser.lua:
----------
This script calls set_focus(...) with user-defined pauses in between. It either increases the subject distance by a constant each step or follows an exponential curve. I highly recommend the latter!

My camera ignores set_focus(...) in AF and I couldn't get it switched to MF from within the script. So the default values rely on the user manually selecting MF.

Caution when using the "Reverse" mode: If you minimum focus distance is below what the camera supports you will be caught in an infinite loop. A workaround could be to abort after a number of steps during which get_focus() didn't change its return value... But I'm done with it for now.

Since my camera stopped reacting completely when I tried to start a script during video recording I added "Wait for set button?" so you can start the script beforehand without having to time the initial delay exactly.


focusdiag.lua
----------
Auxilliary tool to find useful parameters for focusser.lua. Press "set" to see the current focus value from get_focus().



I hope this helps. Feel free to ask for additional features or explanations!

Canon Powershot D30 w/ CHDK 1.3.0

My camera ignores set_focus(...) in AF and I couldn't get it switched to MF from within the script. So the default values rely on the user manually selecting MF.
According to the platform_camera.h file for your D30,  it should accept the set_mf() command in autofocus mode or with MF enabled.  However,  I don't think (?) MF test results were done for the D30 - or at least they are not reported here :  Setting focus from scripts or menus so this could be another C&P error.

To make your script somewhat generic  (i.e. camera model agnostic) you can use the get_sd_over_mode() function to determine which modes will allow the set_mf() command to work.    The options include none,  Autofocus (works with no additional requirements),  AFL (use set_aflock(1) to engage), or MF (use set_mf(1) to engage).  You can then call the appropriate function in your script to put the camera into a mode where it will accept set_focus() commands.

Ported :   A1200    SD940   G10    Powershot N    G16

Continuing on my previous post,  it would be good if you can run mftest.lua on your D30 and report results here  :

link > http://chdk.setepontos.com/index.php?topic=11078.0]Setting focus from scripts or menus[/url]

link > mftest.lua

The D30 porting thread contains a request for one of the original testers to try this but there was apparently no response to that request.
Ported :   A1200    SD940   G10    Powershot N    G16

I haven't gotten around to using get_sd_over_mode() yet, mostly because CHDK's Lua apparently doesn't come with bitwise operator or even math.floor().

Attachment: Test results from the mftest.lua that came with my CHDK build. One fresh after startup, one after setting to MF manually.

Oh, it wrote a CSV! I'll attach that in the post below.
Canon Powershot D30 w/ CHDK 1.3.0


mf_d30.csv
Canon Powershot D30 w/ CHDK 1.3.0

I haven't gotten around to using get_sd_over_mode() yet, mostly because CHDK's Lua apparently doesn't come with bitwise operator or even math.floor().
Huh?
http://chdk.wikia.com/wiki/Lua/Lua_Reference#bitwise_operations
http://chdk.wikia.com/wiki/Lua/Lua_Reference#Integer_Conversion_and_Rounding

You might find this wiki page helpful :  CHDK Scripting Cross Reference


Quote
Attachment: Test results from the mftest.lua that came with my CHDK build. One fresh after startup, one after setting to MF manually. Oh, it wrote a CSV! I'll attach that in the post below.
Cross posted here : http://chdk.setepontos.com/index.php?topic=11078.msg121243#msg121243
Ported :   A1200    SD940   G10    Powershot N    G16

(Sorry about the confusion. I only realized you wanted me to post over there after I submitted the data. I'll stick to here now though as you suggested.)

Quote
funny focus mode
Yup, I did the MF run last so the CSV above is from that one.

Here's one from AF mode.
Canon Powershot D30 w/ CHDK 1.3.0



I'm trying to automize the script further in a more generic way.
Is there a camera-independent way to see if set_mf(1) worked?
Canon Powershot D30 w/ CHDK 1.3.0

I'm trying to automize the script further in a more generic way.
Is there a camera-independent way to see if set_mf(1) worked?

It's not perfect,  but I've used this in the past :
Code: [Select]
    props=require("propcase")
...
    if (get_prop(props.FOCUS_MODE) == 1) then printf(" MF enabled") else printf(" MF enable failed ***") end
Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal