DoF values and other related items - General Discussion and Assistance - CHDK Forum

DoF values and other related items

  • 50 Replies
  • 27523 Views
DoF values and other related items
« on: 19 / November / 2009, 23:24:06 »
Advertisements
I have been doing some work on the DoF display for my own build and wanted to share if others are interested in some of the particulars.

1.  Currently DoF information only displays in m units, I have added capability to select different base units: m, mm, ft, in  (this may be of particular use to Americans or others who are more familiar with ft/in).  Because of the digits needed to display, I have also added a separate display mode: in addition to the classic "separate" and "in misc" modes, I have added a "stacked" option that uses a separate window, but stacks them vertically (similar to misc.) with appropriate decimal places and digits.  If anyone is interested I can submit a diff file to be added to the trunk or do some test builds. (See attached screen shots)

2.  I conjunction with this, I am finding that the values aren't working according to my understanding.  The "subject distance" value being used seems to correspond to the distance to near the rear of the camera (focal plane perhaps) and not the lens front.  DoF field values should be calculate drelative to the optical center by my understanding, which I would assume is the front lens.  This isn't a big deal at long distances, but is very noticeable at close distances (particularly my SX10 which has a LONG distance from lens to focal plane when fully extended.  Hyperfocal distance is fine except it is relative to the optical center, not lens.  However, when calculating near and far, the distance value used should again be that from optical center (not focal plane which is what subject/focal distance appears to be).  Now this is can be easily correctable if the distance from the focal plane to lens front is known.  In some models (VXWorks only?) a camera function is available: "GetFocusLensSubjectDistanceFromLens" which can be used (GetCurrentTargetDistance-GetFocusLensSubjectDistanceFromLens=distnace from lens to focal plane, this seems to measure correctly on my A570) however this function isn't available (or at least hasn't been found) for DryOS models.  Finding this value or similar would help in correcting DoF calculations.

3. Along the lines of DoF, I am going to add on the capability of adding on an external macro lens (eg I have the Raynox DCR250, which is a +8 dipoter lens: lets me use my 20X telephoto zoom at macro distances) which, when included would correct the DoF values in relation to having the additional lens added on.  This is part of the reason I worked on #1, as in/mm are much friendlier macro distance units.  However, getting this to work properly is largely dependent on #2 as dipoter stacking calculations are also done from the lens or optical center. I would rather internal, calibrated camera values be used and available rather that making a manually made function that would be camera model dependant.

Any feedback or help with these items would be appreciated.

Re: DoF values and other related items
« Reply #1 on: 20 / November / 2009, 06:35:12 »
DoF field values should be calculate drelative to the optical center

No .. to the anterior and posterior principal  points .. which you do not know.
You could determine them by experiment, they would change with every zoom position.
For some cameras that would be over 120 different positions.

Quote
this is can be easily correctable if the distance from the focal plane to lens front is known.
SDM displays that information on one of its OSD's.

Quote
 Finding this value or similar would help in correcting DoF calculations.

It has been found for some cameras, check the SDM source code.

Initially, I supported Imperial units of measure with SDM but decided to remove them because the entire World is officially metric (apart from Burma, Liberia and the US).

The early versions of SDM had extensive DOF-based data on the OSD's.

I deleted the lot.

Why ?

Because the camera cannot measure distance accurately, so the whole excercise is a waste of time.

« Last Edit: 20 / November / 2009, 07:20:09 by Microfunguy »

Re: DoF values and other related items
« Reply #2 on: 20 / November / 2009, 08:39:16 »
DoF field values should be calculate drelative to the optical center

No .. to the anterior and posterior principal  points .. which you do not know.
You could determine them by experiment, they would change with every zoom position.
For some cameras that would be over 120 different positions.

Hmm, I may be misunderstanding this then.  Most of the resources I've looked at say this
http://www.tpub.com/content/photography/14209/css/14209_39.htm
"The hyperfocal distance of a lens is the distance from the optical center of the lens to..."
I am also assuming that the optical center is the front lens, however this may not be true.


Quote
Quote
this is can be easily correctable if the distance from the focal plane to lens front is known.
SDM displays that information on one of its OSD's.
Quote
  Finding this value or similar would help in correcting DoF calculations.

It has been found for some cameras, check the SDM source code.

Even for DryOS cameras? I'll have to have a look maybe then.  For CHDK, there isn't a signature for it for the autobuild.


Quote
Initially, I supported Imperial units of measure with SDM but decided to remove them because the entire World is officially metric (apart from Burma, Liberia and the US).
While it's true that most of the world is metric (including Canada where I'm from), a lot of the working world still functions, thinks and visualizes in imperial.  As part of my job, I regularly work in both.

I was interested in adding at least mm and inches to my own build for macro photo purposes (not that it's difficult to convert the m distances to mm in your head, I just prefer to see it that way), and figured it wouldn't really be much to add it to the trunk, especially since it is not camera-dependent, for anyone else who was interested.


Quote
The early versions of SDM had extensive DOF-based data on the OSD's.

I deleted the lot.

Why ?

Because the camera cannot measure distance accurately, so the whole excercise is a waste of time.
I know that it isn't accurate measurements, but they can still be of some use for getting a general idea of the shot setup.  I was espescially interested in doing the third part of my original post, adding +diopter capability so I can get some DoF feedback relative to what the macro lens is giving me.


Re: DoF values and other related items
« Reply #3 on: 20 / November / 2009, 09:05:09 »
"The hyperfocal distance of a lens is the distance from the optical center of the lens to..."

It is incorrect.

Check this  http://hyperphysics.phy-astr.gsu.edu/HBASE/geoopt/priplan.html

The lens-to-sensor distance was calculated from physical measurements  taken with digital vernier calipers by testers.

I did play-around with doing more accurate macro calculations for my A620 but did not pursue it because for SDM I would need the information for all cameras.

Also, I could not see the point of knowing the macro DOF, how does it help ?

By magnification alone, the effective aperture is already smaller and any attempt to stop-down degrades resolution.

Instead, I added a function that automatically takes a stack of images starting at your macro-focused distance and continuing until infinity focus reached.
The focus-step is adjusted at each stage.
Only one mm when very close and after one metre reaching infinity in just a couple of steps.
« Last Edit: 20 / November / 2009, 09:44:13 by Microfunguy »

Re: DoF values and other related items
« Reply #4 on: 20 / November / 2009, 10:05:39 »
"The hyperfocal distance of a lens is the distance from the optical center of the lens to..."
It is incorrect.
Check this  http://hyperphysics.phy-astr.gsu.edu/HBASE/geoopt/priplan.html
This should be correct as it how it is consistently defined elsewhere as well (I had a better resource last night that I can locate now).

I think it does correspond with your reference, as the front principal plane (H1) essentially seems to be equivalent to the optical center of a lens.
The main issue is where the optical center or front principal plane is vs where it is assumed:
For a thin lens, this will be (ideally) at the middle of the lens.
For complex lenses, this may not be exactly in the front lens, but reasonably close to it (close enough for approximate DoF calculation purposes).

Re: DoF values and other related items
« Reply #5 on: 20 / November / 2009, 10:20:28 »
Subject distance is measured from the front principal plane.
Image distance is measured from the rear principal plane.

The front principal plane can be behind the rear principal plane !

The principal planes can also be way outside the lenses.

Without knowledge of the principal plane locations you cannot make accurate calculations, especially at macr distances.

If you know those locations, the lens formulae work as expected.

You can determine these positions experimentally with a detached lens, I have spent many happy hours doing so.

For the SX200IS, for example, you would need to determine those locations for 126 zoom positions or measure at the seven zoom positions defined in the code and extrapolate.

I guess that I am also saying ... what is the point ?

Just because you can calculate a value with CHDK does not mean that you should.

« Last Edit: 20 / November / 2009, 10:24:32 by Microfunguy »

Re: DoF values and other related items
« Reply #6 on: 20 / November / 2009, 10:29:06 »
Subject distance is measured from the front principal plane.
Image distance is measured from the rear principal plane.
If you know those locations, the lens formulae work as expected.
You can determine these positions experimentally with a detached lens, I have spent many happy hours doing so.
I guess that I am also saying ... what is the point ?
Just because you can calculate a value with CHDK does not mean that you should.
There are some general uses for it.  I don't particularly need to know hyperfocal distance at present, but I would like to know what my approximate focus distances and depth of field are for macro photography.
I would also like to know these values relative to the front of my lens.

As I originally stated, these are things I'm modifying for my own personal build, but if there is general interest in improvement on what's in the general build, I can submit the diff patches when completed.
The main things I was working towards are:
1)I'd rather see my distances in mm or in when needed
2)I'd like to supplement the values for add on macro lenses (ie any of the Raynox macro lenses)

In trying to go through this is when I found some discrepencies or missing parts of the DoF calculations which I am currently trying to solve for.

Re: DoF values and other related items
« Reply #7 on: 20 / November / 2009, 13:19:57 »
 :D Yay!
I believe I have found the "GetFocusLensSubjectDistanceFromLens()" function in the SX10 103a at address FF93A6B8.
I basically did a firmware search looking for a similar structure and pointer setup to that of the A570.

adding:
NSTUB(GetFocusLensSubjectDistanceFromLens, 0xFF93A6B8)
to stubs_entry_2.s

and testing (subtracting this from subject distance) gives me lengths ranging from 87mm at full wide to 118mm at full zoom which correspond to physically measured lengths.

Re: DoF values and other related items
« Reply #8 on: 20 / November / 2009, 13:29:43 »
I believe I have found the "GetFocusLensSubjectDistanceFromLens()" function in the SX10 103a at address FF93A6B8.

Good find, discussion is worth it just for that   :)

Re: DoF values and other related items
« Reply #9 on: 20 / November / 2009, 14:02:21 »
I believe I have found the "GetFocusLensSubjectDistanceFromLens()" function in the SX10 103a at address FF93A6B8.

Good find, discussion is worth it just for that   :)

Thanks.  Further to this, I believe a couple of the other related functions have incorrect pointers/signatures for DryOS (at least relative to their VXWorks counterparts)

These are for SX10 103a in particular:

NSTUB(GetCurrentTargetDistance, 0xff93a3ac)
I believe that this is actually the entry point for the vxworks equivalent function "GetFocusLensSubjectDistance".  It is a much larger function in DryOS than VXWorks, but has the same general idea (and is referenced in a similar manner which is how I tracked "GetFocusLensSubjectDistanceFromLens" down)
I believe the actual entry point for GetCurrentTargetDistance is at FF8C8E14 which is a function similar in structure to that of VXWorks.

NSTUB(GetFocusLensSubjectDistance, 0xffa63098) ---->incorrect?
This is the current entry used, but, as referred to in the code, it returns a string and has hence been disabled (With GetCurrentTargetDistance being substituted).  See above.

Making these two alterations to the code seems to operately properly, or at least in the same manner as similar operations in VXWorks.
I don't think that there is a big deal in these two functions being incorrect other than for consistency with VXWorks function. As both seem to return the same number (GetCurrentTargetDistance actually calls GetFocusLensSubjectDistance and does a little extra processing on the result, on VXWorks it is a simple LSL/LSR operation, on DryOS it does some additional checking which I haven't really parsed out).

Restoring all three of these function entry points to be consistent would enable the code that is currently in the "wrappers.c" files for each individual camera model (this is the only code in them) to be moved to "generic/wrappers.c" and remove the duplication.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal