Ask Your Question
4

Performance evaluation for detection

asked 2012-07-04 15:14:53 -0600

icedecker gravatar image

updated 2012-07-04 18:12:54 -0600

I'm trying to evaluate some cascades I have trained with trainingcascade.cpp. So I would like to know if using the intersection of two rectangles (the reference rect and the detected rect) is a good metric. The criteria would be something:

if intersect.area() > (0.9*ref.area())
   hit++
else 
   miss++

It is good enough to evaluate? I have looked the code in opencv_performance, but did not understood well the metric used here. It is a code for rect intersection or another thing?

Thanks!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
7

answered 2012-07-04 15:34:31 -0600

AlexanderShishkov gravatar image

updated 2012-07-04 15:49:33 -0600

Ordinary I use the following metric: area(intersection(rect1,rect2)) / area(union(rect1,rect2)) > 0.5

If you use the C++ way (cv::Rect), you can easily say

interesect  = r1 & r2;

for intersection calculation.

For CvRect:

CvRect intersect(CvRect r1, CvRect r2) 
{ 
    CvRect intersection; 

    // find overlapping region 
    intersection.x = (r1.x < r2.x) ? r2.x : r1.x; 
    intersection.y = (r1.y < r2.y) ? r2.y : r1.y; 
    intersection.width = (r1.x + r1.width < r2.x + r2.width) ? 
        r1.x + r1.width : r2.x + r2.width; 
    intersection.width -= intersection.x; 
    intersection.height = (r1.y + r1.height < r2.y + r2.height) ? 
        r1.y + r1.height : r2.y + r2.height; 
    intersection.height -= intersection.y; 

    // check for non-overlapping regions 
    if ((intersection.width <= 0) || (intersection.height <= 0)) { 
        intersection = cvRect(0, 0, 0, 0); 
    } 

    return intersection; 
}
edit flag offensive delete link more

Comments

Thanks, Alexander! I'm doing in the C++ way. I thought that intersection would be sufficient, the use of union is a good idea. For the union, the code would be Rect rectunion = rectdet | rect_ref, right?

icedecker gravatar imageicedecker ( 2012-07-04 15:57:40 -0600 )edit
1

minunionrect = det | ref, for fair union area calculation you shoud write more complex code

AlexanderShishkov gravatar imageAlexanderShishkov ( 2012-07-04 16:01:37 -0600 )edit
1

Yes, for area of union, a bit of code is necessary. The calculation for union would be something like as: rect_union.area() = r1.area() + r2.area() - intersection.area().

icedecker gravatar imageicedecker ( 2012-07-04 16:15:12 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2012-07-04 15:14:53 -0600

Seen: 2,866 times

Last updated: Jul 04 '12