当前位置:   article > 正文

C语言计算旋转矩形的IOU,计算两个矩形IOU的算法

c语言怎么实现矩阵的iou

float intersectRect(const cv::Rect& rectA, const cv::Rect& rectB, cv::Rect& intersectRect){

if (rectA.x > rectB.x + rectB.width) { return 0.; }

if (rectA.y > rectB.y + rectB.height) { return 0.; }

if ((rectA.x + rectA.width) < rectB.x) { return 0.; }

if ((rectA.y + rectA.height) < rectB.y) { return 0.; }

float colInt = min(rectA.x + rectA.width, rectB.x + rectB.width) - max(rectA.x, rectB.x);

float rowInt = min(rectA.y + rectA.height, rectB.y + rectB.height) - max(rectA.y, rectB.y);

float intersection = colInt * rowInt;

float areaA = rectA.width * rectA.height;

float areaB = rectB.width * rectB.height;

float intersectionPercent = intersection / (areaA + areaB - intersection);

intersectRect.x = max(rectA.x, rectB.x);

intersectRect.y = max(rectA.y, rectB.y);

intersectRect.width = min(rectA.x + rectA.width, rectB.x + rectB.width) - intersectRect.x;

intersectRect.height = min(rectA.y + rectA.height, rectB.y + rectB.height) - intersectRect.y;

return intersectionPercent;

}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/114157
推荐阅读
相关标签
  

闽ICP备14008679号