12,509,269 members (57,711 online)
Rate this:
See more:
How I can calculate distance between every 2 points and then get their ratio ratio?
Here is the idea. It's for face recognition, idea is to detect every eye separately and nose. Center of detection is one point(how to set that point?). Then I need to calculate distance between two eyes and then lets say left eye and nose. At the end get the ratio of this 2 distances.
Posted 22-Nov-12 21:30pm
retexis374

Rate this:

## Solution 2

to calculate distance you must apply such this function :
public int Distance2D(int x1, int y1, int x2, int y2)
{
//     ______________________
//d = &#8730; (x2-x1)^2 + (y2-y1)^2
//

//Our end result
int result = 0;
//Take x2-x1, then square it
double part1 = Math.Pow((x2 - x1), 2);
//Take y2-y1, then sqaure it
double part2 = Math.Pow((y2 - y1), 2);
//Add both of the parts together
double underRadical = part1 + part2;
//Get the square root of the parts
//Return our result
return result;
}
retexis 23-Nov-12 12:22pm

Thank you very much, that's exactly what I am looking for.
Rate this:

## Solution 1

Distance between two points is easy: it's Pythagorus's theorem:
dist = Square Root(Square(Diff(X1, X2)) + Square(Diff(Y1, Y2)))

Ratio is also easy: divide one by the other.

Finding the points? Over to you - it's a lot harder!
Have a look at some of these: Google: "Face Recognition Codeproject"[^]

Top Experts
Last 24hrsThis month
 OriginalGriff 321 Suvendu Shekhar Giri 170 Maciej Los 165 CPallini 140 Richard Deeming 135
 OriginalGriff 7,907 ppolymorphe 4,062 Maciej Los 3,981 David_Wimbley 3,306 Karthik Bangalore 3,151