Calculate the area of a bounding box

Hello everyone,

I am working with the RI5 and PicameraV3 on a Raspberry Pi using Hailo’s AIKit, and I am relatively new to this. I would like to know if it is possible to use the function get_scaling_bbox to calculate the area of a bounding box. If so, could someone guide me on how to incorporate this function into my workflow to obtain the box area?

I have tried various approaches to obtain the area of a box, but I cannot retrieve the coordinates of the box. The x and y coordinates are always displayed as 1, 1, whether I use the camera or demo videos—the results are the same. Does anyone know how to correctly obtain the box coordinates?

Any advice or examples on how to integrate this would be greatly appreciated. Thank you!ely new to this. I would like to know if it is possible to use the function get_scaling_bbox to calculate the area of a bounding box. If so, could someone guide me on how to incorporate this function into my workflow to obtain the box area?

Any advice or examples on how to integrate this would be greatly appreciated. Thank you!

Not sure if I understand your issue correctly. Here is an example to incorporate the bounding boxes in a frame for all detections. You need to include the corresponding code into detections.py in the hailo-rpi5-examples folder.

    <.....>
    my_x_min = []
    my_y_min =[]
    my_x_max = []
    my_y_max =[]
    
    for detection in detections:
        bbox = detection.get_bbox()
        # Call the coordinate methods
        my_x_min.append(bbox.xmin()*640)
        my_y_min.append(bbox.ymin()*640)
        my_x_max.append((bbox.xmin()*640 + bbox.width()*640))
        my_y_max.append((bbox.ymin()*640 + bbox.height()*640))
            
   <......> 
        for x in range(len(my_x_min)):
            cv2.rectangle(frame, (int((my_x_min[x])), int((my_y_min[x]))), (int((my_x_max[x])), int((my_y_max[x]))), (0, 0, 255), 2)