**Talk:**UBASIC/Scripts: yet another DOF stacker

## Back to page | < Talk:UBASIC

*588*pages on

this wiki

Can someone write exactly what needs to be pressed and when to get this script to work? Every time I try to use this it only takes one picture and says finished. I cant figure out whats wrong. Thanks =)

I *really* like the way this is implemented. I was hoping to do something similar one day, but I like your method much nicer than what I had in mind. I notice that your script relies on tables for the aperture and zoom values. If I was to convert this for the S-series cameras would it be easy? Where would I find those tables, and would it require 129 entries for each and every zoom step? The aperture values table should be just as short, yes?

Thanks for doing this. I hope I can make it useable.

If someone (=you?) gets this working on S3, please do share your knowledge. Don't be shy. :] Perhaps the focal length table could be (again) based what's found in grand/platform/s3is/main.c. One could easily(?) calculate all 122 "missing" focal length values. Or just write the method for calculating them (for-loop?) into the script. (from S3's main.c)

static const struct { int zp, fl; } fl_tbl[] = { { 0, 6000 }, { 11, 6400 }, { 41, 12100 }, { 64, 21300 }, { 86, 41600 }, { 105, 61400 }, { 128, 72000 }, }; #define NUM_FL (sizeof(fl_tbl)/sizeof(fl_tbl[0])) ... int get_focal_length(int zp) { int i; if (zp<fl_tbl[0].zp) return fl_tbl[0].fl; else if (zp>fl_tbl[NUM_FL-1].zp) return fl_tbl[NUM_FL-1].fl; else for (i=1; i<NUM_FL; ++i) { if (zp==fl_tbl[i-1].zp) return fl_tbl[i-1].fl; else if (zp==fl_tbl[i].zp) return fl_tbl[i].fl; else if (zp<fl_tbl[i].zp) return fl_tbl[i-1].fl+(zp-fl_tbl[i-1].zp)*(fl_tbl[i].fl-fl_tbl[i-1].fl)/(fl_tbl[i].zp-fl_tbl[i-1].zp); } return fl_tbl[NUM_FL-1].fl; }

In A710 this table was much easier, the code reads just:

static const int fl_tbl[] = {5800, 6420, 7060, 7700, 8340, 9950, 11550, 13160, 14750, 17150, 19570, 22760, 26750, 30750, 34800}; #define NUM_FL (sizeof(fl_tbl)/sizeof(fl_tbl[0])) ... int get_focal_length(int zp) { if (zp<0) return fl_tbl[0]; else if (zp>NUM_FL-1) return fl_tbl[NUM_FL-1]; else return fl_tbl[zp]; }

--Jucifer

- Thanks MUCH for this further info. But that programming language is beyond my comprehension, and beyond my desire to learn a whole new one just for this. :) What I did do is plot the known values on a graph and saw the unique S-curve it makes. When I have the time I will have to do it manually on a graph and pick out the values for all 129 spots. I tried using a program called "FindGraph" that plots a curve to known sample points, but I can't get it to do what I need. It has a pretty steep learning curve too. It plots a nice curve to approximate those sample points on one of the available plotting types but it some of the curve is outside of the known values. So I may have to do it manually using some vector curve plotting on a graph grid.
- Just how important is the accuracy of those values? If I pick them off of a graph of just straight lines from point to point would that be just as accurate as the function that is already being used for the S-series cameras? If that's the case it would be much easier than trying to fit bezier vector curves to those data points. I could pick off all 129 values in just one evening from straight lines from point to point instead of trying to plot a complex curve to precisely fit them all.

- re: S3 Table -- I just found that you added the table of S3 values!! Thanks!! It might have been another month before I would have drummed up the patience to find all the values. :-)

- Ooops, just noticed something, shouldn't that table have all
**if z=**instead of**if v=**commands?

- Ooops, just noticed something, shouldn't that table have all

- Oopsy, yes indeed. :I FL table should now be correct. Also should have checked earlier whether aperture values are better smaller or bigger. Smaller values produce shorter DOF, thus being "safer". And now that I think of it, bigger Av = longer DOF...
- --Jucifer

- And yet another ooops, I realized now in seeing your correction that I left all the
**then let v=**in error too. :-) (I noticed the original problem when I was dead tired and missed the full correction.) Thanks again for the addition and the correction! I'm sure I'll make good use of this! Now to find someone with an A6x0 to see what their aperture values are and it should be good to go for ALL supported cameras. Way cool! I think if people see this and realize how it is being done that your method should and will become the default focus-bracket script. ~Keo~

- And yet another ooops, I realized now in seeing your correction that I left all the

Can some explain how the Av tables were derived, in particular for the S3? From platform/generic/shooting.c, what's happening is that the following formula gets applied to the table in platform/s3is/shooting.c

>> round( 100*sqrt(2).^([283, 320, 352, 384, 416, 448, 480, 512, 544, 576]/96)) ans = 278 317 356 400 449 504 566 635 713 800

There's a missing factor of 10 that comes in later, in the calculation of the hyperfocal distance in core/gui_osd.c -- but the numbers still don't agree with the table provided by Keo. Any idea what's going on here?

More generally, what *are* the units for the focal length (zoom setting, z), aperture Av setting (v), circle of confusion (c=5), and the focus setting (f,t,l,h)? They don't agree! It seems that focus setting is in mm -- but that focal length and circle of confusion are in um=mm/1000, and that Av (after including the factor of 10) is similarly larger by a factor of 1000x. Can anyone verify this? What about the mysterious factor of 96??

128.100.4.23 02:03, 7 February 2008 (UTC)swh