DOF-based focus stack script NOT based on CHDK DOF calculations - page 2 - Script Writing - CHDK Forum

# DOF-based focus stack script NOT based on CHDK DOF calculations

• 15 Replies
• 20456 Views

#### SkyWalker9

• 301
• SX20 IS (fw 1.02b)
##### Re: DOF-based focus stack script NOT based on CHDK DOF calculations
« Reply #10 on: 28 / September / 2011, 11:46:07 »
What exactly should be changed in the original SX30/S5 .bas file in order for the script to work on SX20. Excuse me for the lame question,but I`m not quite familiar with script modding.
Here is how I modified the script for my SX20 back in April - comparison of modified script with the original S5 version:

Original section of code from "DOFstack_S5.bas"  (lines 67-72)
Code: [Select]
`if F<=11 then let f = (362*F+60000)/1000if (F>11 and F<=41) then let f = (1900*F+43100)/1000if (F>41 and F<=64) then let f = (4000*F-43000)/1000if (F>64 and F<=86) then let f = (9227*F-377584)/1000if (F>86 and F<=105) then let f = (10421*F-480190)/1000if F>105  then let f = (4614*F+129543)/1000`
Modified for SX20
Code: [Select]
`if F<=11 then let f = ((F*10455)/100 + 5000)/100if (F>11 and F<=41) then let f = (((F-11)*21533)/100 + 6190)/100if (F>41 and F<=64) then let f = (((F-41)*54913)/100 + 12610)/100if (F>64 and F<=86) then let f = (((F-64)*91955)/100 + 25240)/100if (F>86 and F<=105) then let f = (((F-86)*107421)/100 + 45470)/100if F>105  then let f = (((F-105)*148348)/100 + 65880)/100`
« Last Edit: 29 / September / 2011, 00:09:08 by SkyWalker9 »

#### mark

• 4
##### Re: DOF-based focus stack script NOT based on CHDK DOF calculations
« Reply #11 on: 22 / July / 2014, 22:39:10 »
Hi. Which amendment would have to be made ​​to work in the SX50? I am interested in macro shots, and then do the stack of photos, someone could help me? Thanks.

#### skrylten

• 40
##### Re: DOF-based focus stack script NOT based on CHDK DOF calculations
« Reply #12 on: 23 / July / 2014, 14:37:42 »
Hi Mark,

I made this script for my SX50.
If you want to stop the script before "infinity focus" just press "shoot" again.
The camera has to be in Manual Focus mode.

Attached is an example of a stack made with the SX50 combined with a Raynox MSN202 (no crop)

BR

Leif

Code: [Select]
`rem Focus bracketingrem s focus distancerem f focal lengthrem a fnumberrem c circle of confusion@title SX50 Focus bracketing by Leif Karlsson@param p Max number of steps @default p 300@default c 5sleep 2000  for r=1 to p   shoot   get_focus s   get_zoom f   get_av n   a=100*(s-f)/(f+n*c)   b=100*2*s*f/(f*f+s*n*c-n*c*f)   d=a*b/10000   g=s+d/8   set_focus g   print g,d   if g>50000 then r=p   if d<0 then r=p  next rend`

#### waterwingz

• 12140
##### Re: DOF-based focus stack script NOT based on CHDK DOF calculations
« Reply #13 on: 23 / July / 2014, 18:21:29 »
I made this script for my SX50. The camera has to be in Manual Focus mode.
Using CHDK 1.3.0,  the SX50 will focus manually if you add this line to the start of the script :

Code: [Select]
`set_mf 1`That way you don't need to remember to manually put the camera into Canon MF mode.

You will probably want to to add this just before the end statement as well :

Code: [Select]
`set_mf 0`
Ported :   A1200    SD940   G10    Powershot N    G16

#### mark

• 4
##### Re: DOF-based focus stack script NOT based on CHDK DOF calculations
« Reply #14 on: 24 / July / 2014, 18:58:44 »
Thank you skrylten, for their great help. Your photos are very clear, I will use your script
And waterwingz your tip is interesting, thanks.
I'm new in this world of CHDK and also with the Canon SX50.

#### bugbear

• 57
• A630
##### Re: DOF-based focus stack script NOT based on CHDK DOF calculations
« Reply #15 on: 14 / July / 2016, 07:29:28 »
I've looked at the original script carefully, and I don't understand how it works with a close focus adapter (e.g. the Raynox).

There is no parameter or code that I can see to reflect the presence (or absence) of such a lens?!

Code: [Select]
`grep "@param" DOFstack\ S5.bas @param t Delay for first shot [s] @param d Near focus dist [mm] @param q Far focus dist [mm]@param c Circle of Confusion [um]`

BugBear