Ask Your Question

Calculating the distance between two points

asked 2016-02-11 07:48:17 -0500

super_man1993 gravatar image

How do i calculate the distance between two points in java/ opencv

Point point1 = new Point(10,10);
Point point2= new Point(56, 35);

line(image, point1, point2, new Scalar(100, 100, 100));
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-02-11 09:08:26 -0500

Guyygarty gravatar image

updated 2016-02-11 09:11:22 -0500

I'm not familiar with the Java interface but it should be something like

Point difference=Point1-Point2;
double distance =sqrt( difference.ddot(difference));

you are basically doing:

square root of (point1.x-point2.x)^2+(point1.y-point2.y)^2)


edit flag offensive delete link more


also take a look at this post

sturkmen gravatar imagesturkmen ( 2016-02-12 09:22:29 -0500 )edit

Question Tools

1 follower


Asked: 2016-02-11 07:48:17 -0500

Seen: 8,769 times

Last updated: Feb 11 '16