Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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: bad
good
Please Sign up or sign in to vote.

Solution 2

to calculate distance you must apply such this function :
public int Distance2D(int x1, int y1, int x2, int y2)
       {
           //     ______________________
           //d = √ (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
           result = (int)Math.Sqrt(underRadical);
           //Return our result
           return result;
       }
  Permalink  
Comments
retexis at 23-Nov-12 12:22pm
   
Thank you very much, that's exactly what I am looking for.
Rate this: bad
good
Please Sign up or sign in to vote.

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"[^]
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 365
1 Nirav Prabtani 268
2 Richard Deeming 215
3 CHill60 170
4 _Amy 145
0 OriginalGriff 8,104
1 Sergey Alexandrovich Kryukov 7,045
2 Maciej Los 4,039
3 Peter Leow 3,738
4 CHill60 2,912


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 23 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100