set_focus problem - Script Writing - CHDK Forum

set_focus problem

  • 27 Replies
  • 8946 Views
set_focus problem
« on: 18 / June / 2012, 11:19:20 »
Advertisements
Hi there! I have prolbem with set_focus function:

Code: [Select]
@title Manualfocus
@param h
@default h 5000

shoot
get_focus f

:loop
wait_click
is_key k "right"
if k=1 then gosub "add"
is_key k "left"
if k=1 then gosub "neg"
is_key k "set"
if k=1 then click "shoot_full"
set_focus f
goto "loop"
[b]
:add
get_focus f
print f
f=f+h
print f,";"
set_focus f
return

:neg
get_focus f
print f
f=f-h
print f,";"
set_focus f
return[/b]

end

set_focus does not set up focus (mm) computed in f variable! Problem on Canon PowerShot A3000IS.

Re: set_focus problem
« Reply #1 on: 18 / June / 2012, 13:31:34 »
Does f change at all when you use set_focus, or does nothing happen? Could you post an example of what the script does by putting:

Code: [Select]
print_screen 1
just before "shoot" at the beginning.

Then if you run the script and try to set the focus, then end it and post the contents of the file "LOG_0001.TXT" in the CHDK->LOGS folder, it may be easier to figure out what's going on, as this file will contain everything the script writes to the screen.

(I was initially going to ask if the camera is in Manual Focus mode as cameras with a built-in MF mode need to be for this to work, but your camera does not so I'm not sure yet what's happening).

Re: set_focus problem
« Reply #2 on: 18 / June / 2012, 15:04:18 »
Code: [Select]
4663
9663 ;
4663
9663 ;
4663
9663 ;
4663
9663 ;
4663
9663 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
9663 ;
4663
9663 ;
4663
9663 ;
4663
9663 ;
4663
9663 ;
4663
9663 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
-337 ;
4663
9663 ;
4663
9663 ;
4663
9663 ;
4663
9663 ;
4663
9663 ;
4663
9663 ;
4663
9663 ;
4449
9449 ;
4449
9449 ;
4449
9449 ;
4449
9449 ;
4449
9449 ;
4449
9449 ;
4449
9449 ;
4449
9449 ;
4449
9449 ;
4449
9449 ;
4449
9449 ;
4449
9449 ;
4449
9449 ;
4449
9449 ;
4449
9449 ;
4449
9449 ;
*** INTERRUPTED ***

Re: set_focus problem
« Reply #3 on: 18 / June / 2012, 15:34:18 »
Thanks :) Hmm, that seems strange - do you see any changes in focus on the screen when you run the script? What I'm thinking is that it could either be changing the focus and the get_focus command for some reason is the problem, or that the focus isn't changing and the set_focus command is the problem.

I'm not very experienced with using the focus commands - does anyone know if there are problems with these commands on some cameras?

Re: set_focus problem
« Reply #4 on: 18 / June / 2012, 15:53:32 »
I'am 100% that set_focus does not work. There are no changes in the image on display.

Re: set_focus problem
« Reply #5 on: 18 / June / 2012, 16:29:17 »
I found this - http://arch.ced.berkeley.edu/kap/discuss/comments.php?DiscussionID=3187. Not sure if this is what might happen on your camera, but on the S95 only certain focus distances seem to be allowed. If you could find any that worked (e.g. by writing a script to cycle up a millimetre at a time and read the focus back), then you could adapt the script to remember those certain values.

Hopefully one of the developers can shed more light on what is going on.

Re: set_focus problem
« Reply #6 on: 18 / June / 2012, 20:23:24 »
I wrote a script controlling focus on my S3, and I found that the syntax for get_focus is NOT the same as for set_focus.

get_focus f                 does not work.
f = get_focus              works fine.

Try that little change; it worked for me.  Don't change the set_focus line.

I haven't explored every function in depth, but so far, all the get_xxxx commands appear to work as a variable:
x = get_xxxx

Eric
S3 IS with LensMate filter/hood adapter

*

Offline SkyWalker9

  • ****
  • 301
  • SX20 IS (fw 1.02b)
Re: set_focus problem
« Reply #7 on: 19 / June / 2012, 00:04:44 »
...I haven't explored every function in depth, but so far, all the get_xxxx commands appear to work as a variable: x = get_xxxx
Back in Jan 2011 I wrote a simple script that included all of the 'get_xxxx" statements I found at the time and they were of the format you mentioned 'x = get_xxxx'. The only one that was reversed at the time was the 'get_prop yyy x' statement. There were a couple that didn't seem to work either way, then again that was a long time ago.

I'm attaching the script I used that uses the statements - it saves the results to a LOG file. To run, place the BAS in the CHDK/Scripts folder and the LOG results will be saved to the CHDK/LOGS folder. There is a parameter to change the LOG file name in case you want to experiment with various settings and compare the different LOG results. The parameter number will be saved as part of the LOG name: LOG_0001.TXT, LOG_0005.TXT, etc.

Re: set_focus problem
« Reply #8 on: 19 / June / 2012, 03:33:24 »
In general this syntax:

x=function_that_return_something

looks better, it is common in most of languages. BASIC is strange, when allows syntax:

function_that_return_something x

You can try to use Lua instead of BASIC. It has much more power and the syntax is much more clear.
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

Re: set_focus problem
« Reply #9 on: 19 / June / 2012, 06:42:04 »
Code: [Select]
@title Manualfocus
@param h
@default h 5000

print_screen 1
f = get_focus

:loop
wait_click
is_key k "right"
if k=1 then gosub "add"
is_key k "left"
if k=1 then gosub "neg"
is_key k "set"
if k=1 then click "shoot_full"
set_focus f
goto "loop"

:add
f = get_focus
print f
f=f+h
print f,";"
set_focus f
return

:neg
f = get_focus
print f
f=f-h
print f,";"
set_focus f
return

end

it is still not working.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal