CHDK Wiki
m (added a note after some testing)
(added a "feature" & an "error-check")
Line 4: Line 4:
 
:'''Also works on:''' Should work on A6x0 and S3 with minor modification.
 
:'''Also works on:''' Should work on A6x0 and S3 with minor modification.
   
Last updated on 20070821.
+
Last updated on 20070823.
   
Works with any review setting. If you don't use review (at all), see code line 150 (in loop_shoot).
+
Works with any review setting. If you don't use review (at all), see code line 162 (in loop_shoot).
   
This script tries to make DOF stacking easy & accurate for every aperture & zoom value. (Alas, greater zoom values don't quite work. If someone comes up with a more accurate, yet fast enough approach for changing focus, please share your knowledge.)
+
This script tries to make DOF stacking easy & accurate for every aperture & zoom value. (Alas, greater zoom values don't quite work. If someone comes up with a more accurate, yet fast enough approach(es) for changing focus, please share your knowledge.)
   
Usage is pretty straightforward: dial to M/Av, set parameters, use MF to focus to one end of the desired DOF (MF has to have focus, use +/- to change if necessary...). Run the script and set the other end or press set for inf. No need to estimate subject depths, guess needed steps to get gapless DOF...
+
Usage is pretty straightforward: dial to M/Av, set parameters, use MF to focus to one end of the desired DOF (MF has to have focus, use +/- to change if necessary...). Run the script and set the other end or use zoom_out/zoom_in to set min/max focus value. No need to estimate subject depths, guess needed steps to get gapless DOF...
   
 
The greater the value for a/b, the further the DOF will move.
 
The greater the value for a/b, the further the DOF will move.
Line 84: Line 84:
 
print "-use down/left or"
 
print "-use down/left or"
 
print " up/right to change focus"
 
print " up/right to change focus"
print "-press set for inf"
+
print "-zoom_out for nearest"
  +
print "-zoom_in for inf"
   
   
Line 90: Line 91:
 
cls
 
cls
 
print "-shoot_half continues"
 
print "-shoot_half continues"
print "-press set for inf"
+
print "-zoom_out for nearest"
  +
print "-zoom_in for inf"
   
 
is_key k "left"
 
is_key k "left"
Line 100: Line 102:
 
is_key k "up"
 
is_key k "up"
 
if k=1 then goto "focus_out_more"
 
if k=1 then goto "focus_out_more"
is_key k "set"
+
is_key k "zoom_in"
 
if k=1 then goto "set_inf"
 
if k=1 then goto "set_inf"
  +
is_key k "zoom_out"
  +
if k=1 then goto "set_near"
   
 
 
Line 116: Line 120:
 
is_key k "shoot_half"
 
is_key k "shoot_half"
 
if k=1 then goto "theotherside_set"
 
if k=1 then goto "theotherside_set"
is_key k "set"
+
is_key k "zoom_in"
 
if k=1 then goto "set_inf"
 
if k=1 then goto "set_inf"
  +
is_key k "zoom_out"
  +
if k=1 then goto "set_near"
 
goto "loop_zoom"
 
goto "loop_zoom"
   
Line 140: Line 146:
 
:set_inf
 
:set_inf
 
set_focus 65535
 
set_focus 65535
  +
goto "theotherside_set"
  +
  +
:set_near
  +
rem smallest focus value for A710 is actually 59, what about A6x0 and S3?
  +
set_focus 55
   
 
:theotherside_set
 
:theotherside_set
Line 169: Line 180:
 
rem better move new focus at least a bit
 
rem better move new focus at least a bit
 
if e<1 then e=1
 
if e<1 then e=1
  +
i=f
 
t=(f+e)
 
t=(f+e)
 
set_focus t
 
set_focus t
Line 186: Line 198:
 
click "left"
 
click "left"
 
get_focus f
 
get_focus f
  +
rem if wasn't able to move focus any further, end
  +
if f<=i then goto "almost_there"
 
goto "loop_dec"
 
goto "loop_dec"
   

Revision as of 12:41, 23 August 2007

yet another DOF stacker

Written for/on: Powershot A710
Also works on: Should work on A6x0 and S3 with minor modification.

Last updated on 20070823.

Works with any review setting. If you don't use review (at all), see code line 162 (in loop_shoot).

This script tries to make DOF stacking easy & accurate for every aperture & zoom value. (Alas, greater zoom values don't quite work. If someone comes up with a more accurate, yet fast enough approach(es) for changing focus, please share your knowledge.)

Usage is pretty straightforward: dial to M/Av, set parameters, use MF to focus to one end of the desired DOF (MF has to have focus, use +/- to change if necessary...). Run the script and set the other end or use zoom_out/zoom_in to set min/max focus value. No need to estimate subject depths, guess needed steps to get gapless DOF...

The greater the value for a/b, the further the DOF will move.

Script should now work accurately (enough) and fast on the whole focusing range. Also hyperfocal point is checked; no shots are taken beyond HYP.

If min aperture values are different for A6x0, please do add the needed table(s). (To see them turn on misc OSD items, (zoom 0?, )set short Tv, set Av, half-press shutter, read the Av.)

Thanks to Keo for the S3 Av table.

Feel free to contribute.

Script Code (save as "yaDOFs.bas" to your /SCRIPTS/ folder)

@title yaDOFs
@param a move DOF
@default a 1
@param b by (a/b)
@default b 2
@param c bigger step (up/down)
@default c 5
@param j delay 1st shot (sec)
@default j 5

if a<1 then let a=1
if b<1 then let b=2
if c<1 then let c=5
if j<1 then let j=5

get_av v
get_zoom z
get_focus f


  rem since real Av can't be read by scripts(, right?), tables are based on min Av values ...ish
  rem (to have the error on the safe side)

if v=9 then let v=2870
if v=10 then let v=2950
if v=11 then let v=3220
if v=12 then let v=3910
if v=13 then let v=4310
if v=14 then let v=4800
if v=15 then let v=5350
if v=16 then let v=5900
if v=17 then let v=6440
if v=18 then let v=7820


  rem Focal Length table, based on grand/platform/a710/main.c

if z=0 then let z=5800
if z=1 then let z=6420
if z=2 then let z=7060
if z=3 then let z=7700
if z=4 then let z=8340
if z=5 then let z=9950
if z=6 then let z=11550
if z=7 then let z=13160
if z=8 then let z=14750
if z=9 then let z=17150
if z=10 then let z=19570
if z=11 then let z=22760
if z=12 then let z=26750
if z=13 then let z=30750
if z=14 then let z=34800

  rem HYP calculation based on grand/core/gui_osd.c

h=z*z/5/v

print "-set M/Av and MF"
print "-use down/left or"
print " up/right to change focus"
print "-zoom_out for nearest"
print "-zoom_in for inf"


wait_click
cls
print "-shoot_half continues"
print "-zoom_out for nearest"
print "-zoom_in for inf"

is_key k "left"
	if k=1 then goto "focus_in"
is_key k "down"
	if k=1 then goto "focus_in_more"
is_key k "right"
	if k=1 then goto "focus_out"
is_key k "up"
	if k=1 then goto "focus_out_more"
is_key k "zoom_in"
	if k=1 then goto "set_inf"
is_key k "zoom_out"
	if k=1 then goto "set_near"

	
:loop_zoom
	wait_click
	is_key k "left"
		if k=1 then goto "focus_in"
	is_key k "down"
		if k=1 then goto "focus_in_more"
	is_key k "right"
		if k=1 then goto "focus_out"
	is_key k "up"
		if k=1 then goto "focus_out_more"
	is_key k "shoot_half"
		if k=1 then goto "theotherside_set"
	is_key k "zoom_in"
		if k=1 then goto "set_inf"
	is_key k "zoom_out"
		if k=1 then goto "set_near"
	goto "loop_zoom"

:focus_in
	click "left"
	goto "loop_zoom"
:focus_in_more
	for i=1 to c
		click "left"
	next i
	goto "loop_zoom"
:focus_out
	click "right"
	goto "loop_zoom"
:focus_out_more
	for i=1 to c
		click "right"
	next i
	goto "loop_zoom"


:set_inf
set_focus 65535
goto "theotherside_set"

:set_near
  rem smallest focus value for A710 is actually 59, what about A6x0 and S3?
set_focus 55

:theotherside_set
cls
for t=0 to j-1
	print "waiting", (j-t) "sec"
	sleep 930
next t
cls
get_focus g
if f<g then goto "order_ok"
t=f
f=g
g=t
:order_ok
set_focus f
t=f

:loop_shoot
	  rem last shot @ defined focus
	if t>=g then goto "shoot_last"
	shoot
	  rem no need for additional shots, if last was beyond HYP
	if f>=h then goto "almost_there"
	  rem DOF=R2-R1
	d=((h*f)/(h-f)-(h*f)/(h+f))
	  rem new focus @ current_DOF*a/b
	e=d*a/b
	  rem better move new focus at least a bit
	if e<1 then e=1
	i=f
	t=(f+e)
	set_focus t
	get_focus f
	if f=t then goto "loop_shoot"
	  rem if you don't use review, you can (don't have to) rem the following line (used to cancel review)
	click "shoot_half"
	  rem if focus didn't move at all/is wrong, move it with right&left
	:loop_inc
		if f>t then goto "loop_dec"
		if f=t then goto "loop_shoot"
		click "right"
		get_focus f
		goto "loop_inc"
	:loop_dec
		if f<=t then goto "loop_shoot"
		click "left"
		get_focus f
		  rem if wasn't able to move focus any further, end
		if f<=i then goto "almost_there"
		goto "loop_dec"

:shoot_last
	set_focus g
	shoot

:almost_there


end

Script should work on A6x0 with the focal length table replaced with:

if z=0 then let z=7300
if z=1 then let z=8460
if z=2 then let z=9565
if z=3 then let z=10835
if z=4 then let z=12565
if z=5 then let z=14926
if z=6 then let z=17342
if z=7 then let z=21709
if z=8 then let z=29200

...and S3's focal length table:

if z=0 then let z=6000
if z=1 then let z=6036
if z=2 then let z=6072
if z=3 then let z=6109
if z=4 then let z=6145
if z=5 then let z=6181
if z=6 then let z=6218
if z=7 then let z=6245
if z=8 then let z=6290
if z=9 then let z=6327
if z=10 then let z=6363
if z=11 then let z=6400
if z=12 then let z=6590
if z=13 then let z=6780
if z=14 then let z=6970
if z=15 then let z=7160
if z=16 then let z=7350
if z=17 then let z=7540
if z=18 then let z=7730
if z=19 then let z=7920
if z=20 then let z=8110
if z=21 then let z=8300
if z=22 then let z=8490
if z=23 then let z=8680
if z=24 then let z=8870
if z=25 then let z=9060
if z=26 then let z=9250
if z=27 then let z=9440
if z=28 then let z=9630
if z=29 then let z=9820
if z=30 then let z=10010
if z=31 then let z=10200
if z=32 then let z=10390
if z=33 then let z=10580
if z=34 then let z=10770
if z=35 then let z=10960
if z=36 then let z=11150
if z=37 then let z=11340
if z=38 then let z=11530
if z=39 then let z=11720
if z=40 then let z=11910
if z=41 then let z=12100
if z=42 then let z=12500
if z=43 then let z=12900
if z=44 then let z=13300
if z=45 then let z=13700
if z=46 then let z=14100
if z=47 then let z=14500
if z=48 then let z=14900
if z=49 then let z=15300
if z=50 then let z=15700
if z=51 then let z=16100
if z=52 then let z=16500
if z=53 then let z=16900
if z=54 then let z=17300
if z=55 then let z=17700
if z=56 then let z=18100
if z=57 then let z=18500
if z=58 then let z=18900
if z=59 then let z=19300
if z=60 then let z=19700
if z=61 then let z=20100
if z=62 then let z=20500
if z=63 then let z=20900
if z=64 then let z=21300
if z=65 then let z=22222
if z=66 then let z=23145
if z=67 then let z=24068
if z=68 then let z=24990
if z=69 then let z=25913
if z=70 then let z=26836
if z=71 then let z=27759
if z=72 then let z=28681
if z=73 then let z=29604
if z=74 then let z=30527
if z=75 then let z=31450
if z=76 then let z=32372
if z=77 then let z=33295
if z=78 then let z=34218
if z=79 then let z=35140
if z=80 then let z=36063
if z=81 then let z=36986
if z=82 then let z=37909
if z=83 then let z=38831
if z=84 then let z=39754
if z=85 then let z=40677
if z=86 then let z=41600
if z=87 then let z=42642
if z=88 then let z=43684
if z=89 then let z=44726
if z=90 then let z=45768
if z=91 then let z=46810
if z=92 then let z=47852
if z=93 then let z=48894
if z=94 then let z=49936
if z=95 then let z=50978
if z=96 then let z=52021
if z=97 then let z=53063
if z=98 then let z=54105
if z=99 then let z=55147
if z=100 then let z=56189
if z=101 then let z=57231
if z=102 then let z=58273
if z=103 then let z=59315
if z=104 then let z=60357
if z=105 then let z=61400
if z=106 then let z=61860
if z=107 then let z=62321
if z=108 then let z=62782
if z=109 then let z=63243
if z=110 then let z=63704
if z=111 then let z=64165
if z=112 then let z=64626
if z=113 then let z=65086
if z=114 then let z=65547
if z=115 then let z=66008
if z=116 then let z=66469
if z=117 then let z=66930
if z=118 then let z=67391
if z=119 then let z=67852
if z=120 then let z=68313
if z=121 then let z=68773
if z=122 then let z=69234
if z=123 then let z=69695
if z=124 then let z=70156
if z=125 then let z=70671
if z=126 then let z=71078
if z=127 then let z=71539
if z=128 then let z=72000

...and S3 Aperture Value table (thank you, Keo).

if v=9 then let v=2770
if v=10 then let v=2970
if v=11 then let v=3240
if v=12 then let v=3910
if v=13 then let v=4340
if v=14 then let v=4800
if v=15 then let v=5350
if v=16 then let v=5900
if v=17 then let v=6440
if v=18 then let v=7820

--Jucifer