当前位置:   article > 正文

c/c++---之opencv如何用opencv求IOU_c++ opencv 计算iou

c++ opencv 计算iou
  1. float bbOverlap(const BoundingBox& box1,const BoundingBox& box2)
  2. {
  3. if (box1.x > box2.x+box2.width) { return 0.0; }
  4. if (box1.y > box2.y+box2.height) { return 0.0; }
  5. if (box1.x+box1.width < box2.x) { return 0.0; }
  6. if (box1.y+box1.height < box2.y) { return 0.0; }
  7. float colInt = min(box1.x+box1.width,box2.x+box2.width) - max(box1.x, box2.x);
  8. float rowInt = min(box1.y+box1.height,box2.y+box2.height) - max(box1.y,box2.y);
  9. float intersection = colInt * rowInt;
  10. float area1 = box1.width*box1.height;
  11. float area2 = box2.width*box2.height;
  12. return intersection / (area1 + area2 - intersection);
  13. }
  14. ---------------------
  15. 作者:Belial_2010
  16. 来源:CSDN
  17. 原文:https://blog.csdn.net/kezunhai/article/details/8830882
  18. 版权声明:本文为博主原创文章,转载请附上博文链接!

其中box1,和box2可以用opencv中的Rect2d类。

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

闽ICP备14008679号