x = get_focus()? Return value - General Discussion and Assistance - CHDK Forum supplierdeeply

x = get_focus()? Return value

  • 3 Replies
  • 3336 Views
*

Offline dvip

  • ****
  • 451
x = get_focus()? Return value
« on: 17 / December / 2012, 01:09:20 »
Advertisements
What does get_focus() return if it can't focus?
From time to time I get  -1 as a return value.

This is what I am using to test it:

press "shoot_half"
sleep 1000
get_focus f
sleep 1000
print "Distance in mm: ", f
sleep 1000
release "shoot_half"

Also, I would like to use set_focus to help focus and take 4 images in  increments of 4 feet, any ideas?
I only want to control the focus not the zoom.


*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: x = get_focus()? Return value
« Reply #1 on: 17 / December / 2012, 03:20:48 »
-1 = infinity.

On a lot of cameras you have to be in MF for set_focus to work.

Also the camera may not be able to focus at any arbitrary value; but only at specific steps.
In this case get_focus won't return the value passed to set_focus.

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 dvip

  • ****
  • 451
Re: x = get_focus()? Return value
« Reply #2 on: 17 / December / 2012, 18:29:58 »
>-1 = infinity.

OK, it seems also like get_focus() returns -1 when the camera can't focus,
the objects were less than 10 feet away but hard to focus on, due to low light.
It could be that the camera sets the lens to infinity when trying to guess focus :)

For infinity I use:
set_prop(6, 3)
I wonder if set_focus(-1) will do it too.


>On a lot of cameras you have to be in MF for set_focus to work.

OK.
It works fine on the SX40HS-100i and on the A590is-101b.
I always have the cameras on M mode and the lens on AF not on MF.

>Also the camera may not be able to focus at any arbitrary value; but
>only at specific steps.
>In this case get_focus won't return the value passed to set_focus.

Will these steps be only the same values that get_focus() returns?
I have used some of them and it works fine.

Thanks, Phil.


*

Offline tonyb

  • *
  • 14
Re: x = get_focus()? Return value
« Reply #3 on: 20 / December / 2012, 21:13:05 »
set_focus(-1) works.


 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal