Page 1 of 1

### Calculating distance between 2 dots

Posted: Sun Mar 15, 2009 9:05 pm
Hi,

I'm new to all this so don't mind if I ask any stupid questions. I'm trying some computer vision stuff purely out of interest.

I have a 1.3mega pixel webcam producing a 1280x1024 image. The distance between the webcam and the target is 30cm.

I have 2 white dots which I can recognize and I can measure the distance between these 2 dots in pixels but how do I convert this pixel count into milimeters?

### Re: Calculating distance between 2 dots

Posted: Sun Mar 15, 2009 9:19 pm
Hello,

I am not really sure it is possible to do this, if you don't know how many pixels are in one centimeter when acquiring an object from certain distance. I would suggest you to do some calibration before - put a meter (or another known measure) at 30 cm away from camera and get its width in pixels. Then you may use this information for calculation of distance between two pixels acquired at 30 cm distance from camera.

### Re: Calculating distance between 2 dots

Posted: Sun Mar 15, 2009 10:22 pm
Hi Andrew, thanks for the reply. I have thought about that as a calibration method but then I started to think about accuracy and figured that that isn't an accurate measure to use as it all depends on the accuracy of the measuring tape and your eyes.

What I reckon is that if I had the pixel density and the area of the CCD in my webcam and the angel of the lens then I could accurately calculate the distance between the two dots using some simple geometry but I have no idea how I can get to any of that information... Should I use a more professional camera?

Once I can measure the static distance between the two dots I'm planning on taking is a step further and try to measure the distance between the two dots while they're moving. My goal is to achieve micrometer accuracy but millimeter accuracy will do for my first attempt I guess.

My last step will be to track and measure the distance between several dots while they're moving freely about. For this I need shape recognition I guess... Any helpful example code for doing this?

### Re: Calculating distance between 2 dots

Posted: Mon Mar 16, 2009 6:42 am
Hello,

saykoshey wrote:Should I use a more professional camera?

Check all camera's parameters you need with camera manufacturer. If you use conventional USB camera, then I am not sure you will get such details. However you will not get also accuracy you want with those. So it looks like professional camera is what you need.