Compare two bounding boxes with each other Matlab

Tak picture Tak · Mar 11, 2014 · Viewed 14.2k times · Source

I have two the co-ordinates of two bounding boxes, one of them is the groundtruth and the other is the result of my work. I want to evaluate the accuracy of mine against the groundtruth one. So I'm asking if anyone has any suggestions

The bounding box details is saved in this format [x,y,width,height]

Answer

Autonomous picture Autonomous · Mar 11, 2014

Edit: I have corrected the mistake pointed by other users.

I am assuming you are detecting some object and you are drawing a bounding box around it. This comes under widely studied/researched area of object detection. The best method of evaluating the accuracy will be calculating intersection over union. This is taken from the PASCAL VOC challenge, from here. See here for visuals.

If you have a bounding box detection and a ground truth bounding box, then the area of overlap between them should be greater than or equal to 50%. Suppose the ground truth bounding box is gt=[x_g,y_g,width_g,height_g] and the predicted bounding box is pr=[x_p,y_p,width_p,height_p] then the area of overlap can be calculated using the formula:

intersectionArea = rectint(gt,pr); %If you don't have this function then write a simple one for yourself which calculates area of intersection of two rectangles.
unionArea = (width_g*height_g)+(width_p*height_p)-intersectionArea;
overlapArea = intersectionArea/unionArea; %This should be greater than 0.5 to consider it as a valid detection.

I hope its clear for you now.