简体   繁体   中英

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.

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM