Mehmet
Mehmet

Reputation: 2278

compute area of bounding box

I have coordinates of two bounding boxes. I want to compare them. How can I compute area of each box?

Coordinates:

   Box1 : 0.20212765957446807 0.145625 0.24822695035460993 0.10875
   Box2:  0.15212765957446807 0.145625 0.25822695035460993 0.8875

overlaping_bbox_area1/bbox_area_image_2

A quantity saying if the bboxes in avarerage are larger or small in image one than in image two.

Upvotes: 2

Views: 10124

Answers (2)

Muhammad Salman
Muhammad Salman

Reputation: 64

def _getArea(box):
    return (box[2] - box[0]) * (box[3] - box[1])

This should do the trick. Structure of Box: [xmin,ymin,xmax,ymax] This should do the trick.

Upvotes: 4

Mehmet
Mehmet

Reputation: 2278

from bbox import BBox2D

box1 = BBox2D([0.20212765957446807, 0.145625, 0.24822695035460993, 0.10875])
box2 = BBox2D([0.6693262411347518, 0.146875, 0.31382978723404253, 0.06875])


print(box2.height * box2.width)
print(box1.height * box1.width)

I have found the solution.

Upvotes: 2

Related Questions