BLUR-37: Add detected object type to BoundingBox.
This commit is contained in:
parent
07b7d24d40
commit
96da101cb4
@ -16,9 +16,12 @@ IOU_THRESH = 0.5
|
|||||||
|
|
||||||
|
|
||||||
class BoundBox:
|
class BoundBox:
|
||||||
def __init__(self, x1, y1, x2, y2):
|
def __init__(self, x1, y1, x2, y2, object=None):
|
||||||
self.x1, self.y1, self.x2, self.y2 = x1, y1, x2, y2
|
self.x1, self.y1, self.x2, self.y2 = x1, y1, x2, y2
|
||||||
self.selected = True
|
self.selected = True
|
||||||
|
if object not in ["face", "plate"]:
|
||||||
|
raise ValueError("object must be either 'face' or 'plate'")
|
||||||
|
self.object = object
|
||||||
|
|
||||||
def select(self):
|
def select(self):
|
||||||
self.selected = True
|
self.selected = True
|
||||||
@ -41,14 +44,14 @@ def detect(image_path: str) -> List[BoundBox]:
|
|||||||
)
|
)
|
||||||
plates = plates[0].cpu().numpy().boxes
|
plates = plates[0].cpu().numpy().boxes
|
||||||
bounding_boxes = []
|
bounding_boxes = []
|
||||||
for boxes in [faces, plates]:
|
for boxes, tag in zip([faces, plates], ["face", "plate"]):
|
||||||
for box in boxes:
|
for box in boxes:
|
||||||
xyxyn = box.xyxy[0]
|
xyxyn = box.xyxy[0]
|
||||||
x1 = int(xyxyn[0])
|
x1 = int(xyxyn[0])
|
||||||
y1 = int(xyxyn[1])
|
y1 = int(xyxyn[1])
|
||||||
x2 = int(xyxyn[2])
|
x2 = int(xyxyn[2])
|
||||||
y2 = int(xyxyn[3])
|
y2 = int(xyxyn[3])
|
||||||
bounding_boxes.append(BoundBox(x1, y1, x2, y2))
|
bounding_boxes.append(BoundBox(x1, y1, x2, y2, tag))
|
||||||
return bounding_boxes
|
return bounding_boxes
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user