필터 지우기
필터 지우기

Overlap area between two bounding boxes

조회 수: 2 (최근 30일)
FARHAD
FARHAD 2014년 6월 10일
답변: Image Analyst 2014년 6월 10일
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))

답변 (1개)

Image Analyst
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.

카테고리

Help CenterFile Exchange에서 Feature Detection and Extraction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by