user1784636
user1784636

Reputation: 23

Calculate distance between 2 objects by calculating the mid points

I have labelled image objects with their respective height ,width and coordinates of bounding box around them in pixels. I have calculated the mid point of both the bounding box.how to compare the mid point of both the objects and calculate distance between two them.

Upvotes: 0

Views: 1856

Answers (1)

Zaphod
Zaphod

Reputation: 1927

I assume you mean the 2D distance within the image? In this case, find the Euclidean distance:

const double dx = a.x - b.x;
const double dy = a.y - b.y;
const double distance = sqrt(dx * dx + dy * dy);

where a and b are your mid-points.

Upvotes: 1

Related Questions