Click here to Skip to main content
15,911,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.

I would like to know, is there anyway how to measure the distance between two objects (set as an image file)?, the pixel distance of the 2 objects will be converted to meters.

Thanks in advance. :)

I am using vb.net, WPF
Posted

To get the upper left point of a control you can use the Control.Location[^] property.

Now, when you get those two points out of your controls, you just need to figure out the center or edge of each one (depending on what your calculation is supposed to do) and then do SQRT(X2 + Y2) and multiply by the pixel to meter ratio you have.


* If you meant to calculate distance between two geo positions based on Latitude and Longitude, check the following Q&A on How to calculate Distance Between Lat And Long[^]

Cheers,
Edo
 
Share this answer
 
v4
Not really, no - not for "normal" images.

Remember, an image is a two dimensional representation of a three dimensional scene, so two "items" a pixel apart could be several miles apart in the real world via the third dimension. To add to your problems, even if the image is of a 2D scene (a bunch of objects on a table, seen from directly above for example) unless the image is taken with scale information included (distance to table and some reference points) you have no idea of the relationship between a pixel and a metre. If you know the size of one of the objects (a reference object) then if you can automatically identify this, you can do it, but that's a pile of work all on it's own.

For a "generic" image picked at random? No chance.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900