Effacer les filtres
Effacer les filtres

Overlap area between two bounding boxes

2 vues (au cours des 30 derniers jours)
FARHAD
FARHAD le 10 Juin 2014
Hi, I need to calculate the overlap area between two bounding boxes in my object detection task to evaluate detection accuracy. I have the following code but I don't know which one is correct. Two different codes have different results. Could someone ask me which one is useful?
%% The following is the first one
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);
unionCoords=[min(x_g,x_p),min(y_g,y_p),max(x_g+width_g-1,x_p+width_p-1),max(y_g+height_g-1,y_p+height_p-1];
unionArea=(unionCoords(3)-unionCoords(1)+1)*(unionCoords(4)-unionCoords(2)+1);
overlapArea=intersectionArea/unionArea; %This should be greater than 0.5 to consider it as a valid detection.
%%The following is the second one
Overlarea=area(intersect(gt,pr))/area(union(gt,pr))

Réponses (1)

Image Analyst
Image Analyst le 10 Juin 2014
If they're different, then only one is right. I'd pick the one that give you the "correct" answer based on what you know from simple algebra. Discard the one with the different, wrong answer.

Catégories

En savoir plus sur Feature Detection and Extraction dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by