From: Arthur Thompson on
I would like to calculate the distance between a camera and a physical object based on the size of the object when projected onto the camera sensor.

In Matlab, I can set the View camera to perspective projection mode with:

camproj('perspective')

....and see the object appear to grow bigger as it moves closer to the camera (as I'm plotting it with plot3.) The object actually just consists of 2 points that are held at a fixed distance from each other parallel to the image plane.

I was wondering if there was a way I could get the apparent distance of the points on the graph (in terms of pixels, inches, whatever) back into Matlab as a numerical value and use that data to solve for the distance from the camera.

Thanks,
Arthur
From: ImageAnalyst on
Let's say that you have a disk in the center 10% of your field of view
for your first image. And in your second image, where the camera/
object distance has decreased, your image is now taking up 90% of the
field of view. How do you know if that object is a kilometer wide
asteroid about to hit you, or if it's a bubble rising in the sample
well plate of your microscope? You can't get the actual size unless
you know other things, like the numerical aperture of your optical
system, etc.
From: Arthur Thompson on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <d092eaa7-a8a0-48ee-9b93-e865eec626b5(a)k10g2000yqa.googlegroups.com>...
> Let's say that you have a disk in the center 10% of your field of view
> for your first image. And in your second image, where the camera/
> object distance has decreased, your image is now taking up 90% of the
> field of view. How do you know if that object is a kilometer wide
> asteroid about to hit you, or if it's a bubble rising in the sample
> well plate of your microscope? You can't get the actual size unless
> you know other things, like the numerical aperture of your optical
> system, etc.

Sorry for the misunderstanding. I designed the object that is now being shown on the image sensor. So I do know its actual size (and distance actually), and I should be able to figure out things like the camera field of view as well. I'm just using Matlab to test the accuracy of the equations I intend to use to calculate distance. However, I have to be able to get the "size on sensor" of the object in order for this to work.
From: ImageAnalyst on
How can you check the accuracy of the equations in MATLAB? Are you
able to remove the lens from the camera and put a ruler in the focal
plane?

If you can get back there, you're in luck. Measure the image size and
compare to your equations (calculated via MATLAB).

If you can't get back there, then all you have are your equations to
give you an *estimate* of the image size in the focal plane but if you
can't get back there, then you can't check if it's accurate or not.

By the way, what are your equations? Are you using "thin lens"
formulas? If so, is your lens fairly thin like on a cell phone
camera, or is it a thick lens (like a zoom lens on a DSLR)? If it's
really important, there are sophisticated lens design programs (OSLO,
FRED, CODE V, etc.) or you can hire a consultant.
 | 
Pages: 1
Prev: for loop with 2 variables
Next: Supress linkaxes