计算两点之间的距离 [英] Calculating distance between 2 points

查看:115
本文介绍了计算两点之间的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何计算每2个点之间的距离,然后得到它们的比率比?
这是主意.它用于面部识别,其思想是分别检测每只眼睛和鼻子.检测中心是一个点(如何设置该点?).然后我需要计算两只眼睛之间的距离,然后说左眼和鼻子.最后获得这2个距离的比率.

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.

推荐答案

要计算距离,您必须应用以下函数:
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;
       }


两点之间的距离很容易:这是毕达哥拉斯定理:
dist =平方根(平方(Diff(X1,X2))+平方(Diff(Y1,Y2)))

比率也很容易:彼此除以.

找到要点?交给您-这要困难得多!
看看其中的一些: [
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"[^]


这篇关于计算两点之间的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆