Script that will fire on focus change? - page 2 - Script Writing - CHDK Forum

Script that will fire on focus change?

  • 23 Replies
  • 16498 Views
Re: Script that will fire on focus change?
« Reply #10 on: 30 / May / 2008, 08:42:36 »
Advertisements
vwalton - are you using the right version of fudgey's script? One is for a Digic II camera, the other is for Digic III. What model is your camera? I'll try to test them during lunch today.

fudgey - I'm thinking that get_focus could make a great special build of your MD script. I've been wanting to use it to try to capture some birds in a park, but the problem is that movement in the distance would set it off. Adding a get_focus test would take care of that. This is on my todo list now :)

Re: Script that will fire on focus change?
« Reply #11 on: 30 / May / 2008, 10:07:31 »
Strikes me that the solution may lie with a change of photographic method rather than CHDK cleverness. ...
Thanks and I agree with your approach, but I have tried that. Exactly that, and many variations. That might produce a better overall average photo but what I need is 4 or 5 very good photos. I get them by just firing away (and unexpectedly, I get the best results if I set it on AUTO).

Re: Script that will fire on focus change?
« Reply #12 on: 30 / May / 2008, 10:10:10 »
vwalton - are you using the right version of fudgey's script? One is for a Digic II camera, the other is for Digic III. What model is your camera? I'll try to test them during lunch today.

It's an S2 and I used the Digic II script. (I tried the Digic III too just to see what would happen - same result).

Any ideas about the unk stmt error? I don't know basic but I have a general idea of programming concepts and I didn't see anything grossly wrong or misspelled.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Script that will fire on focus change?
« Reply #13 on: 30 / May / 2008, 13:25:23 »
It's an S2 and I used the Digic II script. (I tried the Digic III too just to see what would happen - same result).

Which CHDK build are you using? Try a recent Allbest build if you aren't using one.

Any ideas about the unk stmt error? I don't know basic but I have a general idea of programming concepts and I didn't see anything grossly wrong or misspelled.

Hmm... is ubasic case sensitive? I never tried and I'm too lazy to check. Change the first line "@Title FocusFilter" to "@title FocusFilter".

fudgey - I'm thinking that get_focus could make a great special build of your MD script. I've been wanting to use it to try to capture some birds in a park, but the problem is that movement in the distance would set it off. Adding a get_focus test would take care of that. This is on my todo list now

Not a bad idea at all. Only suitable for the slow shoot modes, of course.

Re: Script that will fire on focus change?
« Reply #14 on: 30 / May / 2008, 14:43:00 »
Hmm... is ubasic case sensitive? I never tried and I'm too lazy to check. Change the first line "@Title FocusFilter" to "@title FocusFilter".
- I was thinking the same thing. That was the first thing I tried changing.
- There was an extra "if" in there too.
Quote
:include
   if A>a+c or if A<a-c then goto "restart"
   gosub "shoot"
goto "start"
- it seems that UBasic doesn't like math inside if statements. I had to replace "a+c" and "a-c" with single variables
- I added a "sleep 250" between focusing when no shot is taken. My cam seemed to quit randomly without that
- I copied fudgey's auto mode. I think when possible, auti is the best way to go.
- infinite is 65535

Here's the updated script
Code: [Select]
@title FocusFilter
rem Written by A_Str8

@param a Distance x 5 Inches
@default a 26
@param b Include=1 Exclude=2
@default b 1
@param c Range x 5 Inches
@default c 2
@param y 1=Find Distance
@default y=0

print "Starting"

if b<>2 then b=1
if c<0 then c=0
if a<-1 then a=-1
if a=0 then a=1
c=c*127

if y=1 then goto "check"

if a>516 then a=-1
if a=-1 then a=65535
if a=65535 then goto "start"

a=a*127

:start
   N=a-c
   if N<0 then N=0
   X=a+c
   press "shoot_half"
   do
      get_prop 206 P
   until P=1
   get_focus A
   if b=1 then goto "include" else goto "exclude"
goto "start"

:shoot
   click "shoot_full"
   do
      get_prop 206 P
   until P<>1
return

:include
   if A>X or A<N then goto "restart"
   gosub "shoot"
goto "start"

:exclude
   if A>=N and A<=X then goto "restart"
   gosub "shoot"
goto start

:restart
   release "shoot_half"
   sleep 250
goto "start"

:check
   print "Aim at reference"
   sleep 3000
   press "shoot_half"
   do
     get_prop 206 P
   until P=1
  get_focus a
  release "shoot_half"
  B=a/127
  print B, "x 5 inches"
  sleep 3000
goto "start"
« Last Edit: 30 / May / 2008, 14:44:37 by A_Str8 »

Re: Script that will fire on focus change?
« Reply #15 on: 30 / May / 2008, 16:53:18 »
Just tried fudgey's script and all I get is ***STARTED*** after I push the shutter. I put it into <alt> mode, press and release the shutter while pointed at infinity, and get ***STARTED***. Then I move until I'm pointed at something closer and it never focuses. I've tried in P and AUTO, I've tried pressing and releasing the shutter, and just pressing and holding. I think I'm missing something, or the script doesn't work.

Keep trying guys it looks like we're getting close!!
I just tried fudgey's script and it seems to be working for me.

Re: Script that will fire on focus change?
« Reply #16 on: 31 / May / 2008, 10:16:11 »
I tried the new script and got: uBasic:30 unk stmt

So I figured, that must be the N on line 30 - it doesn't like upper case at all. I changed the whole script into lower case and ran it again. Now I get "starting" in the viewfinder and no uBasic errors, but I can't get it to fire. I left it at the default settings 26 for distance and 2 for range, and it just sits there for about 2 minutes then shuts off. It does focus during that 2 minutes so something is happening, but not what we want.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Script that will fire on focus change?
« Reply #17 on: 31 / May / 2008, 13:42:22 »
I tried the new script and got: uBasic:30 unk stmt

So I figured, that must be the N on line 30 - it doesn't like upper case at all. I changed the whole script into lower case and ran it again. Now I get "starting" in the viewfinder and no uBasic errors, but I can't get it to fire. I left it at the default settings 26 for distance and 2 for range, and it just sits there for about 2 minutes then shuts off. It does focus during that 2 minutes so something is happening, but not what we want.

The only thing I can think of is that your build is ancient enough not to support capitalized variables in ubasic.
Upgrade your CHDK, for instance http://malbe.nm.ru/chdk/.

And remember to disable the flash while testing, problems caused by flash modes can lead us astray.

Re: Script that will fire on focus change?
« Reply #18 on: 31 / May / 2008, 18:08:27 »
The only thing I can think of is that your build is ancient enough not to support capitalized variables in ubasic.

...


Yes that was it. I was using pre14-s2is-100f-148; upgraded to allbest-s2is-100f-50 and now the script runs. It doesn't fire the shutter though - I may be using it wrong and don't have time to double-check right now. I've set:
a=20
b=1
c=5
y=1 (0 didn't work either)

I get a display at the top of the screen which I guess is the distance, but it's in a weird format that I can't decipher, and it doesn't change much as I change where I'm pointing the camera.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Script that will fire on focus change?
« Reply #19 on: 01 / June / 2008, 03:57:23 »
Maybe you should try my script first, with the default parameters it's pretty simple. Just point first at something fairly close by that you know the camera will be able to focus at and work from there.

To know what the camera is doing, you really should enable the DoF calculator to see the current focus distance on your LCD. With the subject distance (SD) and depth of field (DOF) on screen, you can better foresee what's going to be in focus. The way I like to have DoF calculator set is:

Go to CHDK menu OSD -> DOF Calculator and enable for instance "Show DOF Calculator In Misc" and "Shot Subj. Dist. in Misc" and "Show Depth of Field in Misc" and "Subject distance from lens".

Go to CHDK menu OSD -> Miscellaneous Values -> Show Misc Values: Always


 

Related Topics


SimplePortal © 2008-2014, SimplePortal