rem CHDK uBASIC script. Shoot when the camera finds focus closer/furtherrem to a reference distance. At startup, camera must be pointed at rem the reference distance or reference can be given as a parameter.remrem To find a value for the reference parameter, use the auto moderem and read what the script reports you. It may or may not berem in millimeters, this depends on your camera model.remrem Works on Digic III, developed on A570IS. rem Change get_prop 206->205 for Digic II.rem Author: Fudgey on 20080529@title Focus Shoot@param a Reference (0=Auto)@default a 0@param b Closer=0, Further=1@default 0if a=0 then gosub "getreference" else R=aclsprint "Ref is", Rprint "READY, SEARCHING FOCUS."if b=1 then goto "further" else goto "closer":closer press "shoot_half" do get_prop 206 P until P=1 get_focus F if F<R then click "shoot_full" else release "shoot_full" do get_prop 206 P until P<>1goto "closer":further press "shoot_half" do get_prop 206 P until P=1 get_focus F if F>R then click "shoot_full" else release "shoot_full" do get_prop 206 P until P<>1goto "further":getreference cls print "Point at reference object," print "press MENU to get reference" do wait_click is_key K "menu" until K=1 press "shoot_half" do get_prop 206 P until P=1 get_focus R release "shoot_half"return
rem CHDK uBASIC script. Shoot when the camera finds focus closer/furtherrem to a reference distance. At startup, camera must be pointed at rem the reference distance or reference can be given as a parameter.remrem To find a value for the reference parameter, use the auto moderem and read what the script reports you. It may or may not berem in millimeters, this depends on your camera model.remrem Developed on A570IS, modified for Digic II, hopefully works.rem Change get_prop 205->206 for Digic III.rem Author: Fudgey on 20080529@title Focus Shoot@param a Reference (0=Auto)@default a 0@param b Closer=0, Further=1@default 0if a=0 then gosub "getreference" else R=aclsprint "Ref is", Rprint "READY, SEARCHING FOCUS."if b=1 then goto "further" else goto "closer":closer press "shoot_half" do get_prop 205 P until P=1 get_focus F if F<R then click "shoot_full" else release "shoot_full" do get_prop 205 P until P<>1goto "closer":further press "shoot_half" do get_prop 205 P until P=1 get_focus F if F>R then click "shoot_full" else release "shoot_full" do get_prop 205 P until P<>1goto "further":getreference cls print "Point at reference object," print "press MENU to get reference" do wait_click is_key K "menu" until K=1 press "shoot_half" do get_prop 205 P until P=1 get_focus R release "shoot_half"return
A_Str8: AFAIK, different cameras may have different values coming out of get_focus... my a570is gives 65535 for infinity, not -1 like yours. But it doesn't matter with my script anyway, you can either specify the reference distance as a parameter or let the script measure it for you automagically.
I converted mm to inchesx5 because it would be a pain to input further distances in mm.
I take pictures of RC airplanes for a website (rcgroups.com). This involves trying to follow a very fast airplane through the sky and taking a snap when it's in the center of the frame and focused. (Infinity doesn't work.) This works about 1 in 100 times if I try to do it manually. It's very frustrating.
Strikes me that the solution may lie with a change of photographic method rather than CHDK cleverness. ...
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.
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
Hmm... is ubasic case sensitive? I never tried and I'm too lazy to check. Change the first line "@Title FocusFilter" to "@title FocusFilter".
:include if A>a+c or if A<a-c then goto "restart" gosub "shoot"goto "start"
@title FocusFilterrem 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=0print "Starting"if b<>2 then b=1if c<0 then c=0if a<-1 then a=-1if a=0 then a=1c=c*127if y=1 then goto "check"if a>516 then a=-1if a=-1 then a=65535if 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<>1return: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 250goto "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 3000goto "start"