Overlap area between two bounding boxes
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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))
0 Commenti
Risposte (1)
Image Analyst
il 10 Giu 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.
0 Commenti
Vedere anche
Categorie
Scopri di più su Get Started with MATLAB in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!