前言
交并比IOU(Intersection over Union)是一种测量在特定数据集中检测相应物体准确度的一个标准。
图示
很简单,IoU相当于两个区域重叠的部分除以两个区域的集合部分得出的结果。
一般来说,这个score > 0.5 就可以被认为一个不错的结果了。
code
//compute iou. float compute_iou(cv::Rect boxA, cv::Rect boxB) { int xA = max(boxA.x, boxB.x); int yA = max(boxA.y, boxB.y); int xB = max(boxA.x+boxA.width, boxB.x+boxB.width); int xB = max(boxA.y+boxA.height, boxB.y+boxB.height); float inter_area = (xB-xA+1) * (yB-yA+1); float boxA_area = boxA.width * boxA.height; float boxB_area = boxB.width * boxB.height; float iou = inter_area / (boxA_area + boxB_area - inter_area); return iou; }
参考
1.oldpan博客;
完