Overlap area between two bounding boxes
4 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Image Analyst
2014 年 6 月 10 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!