faster-rcnn中utils下几个重要函数的解析

utils下的函数主要是为了整个工程调用的方便而设计的,这里讲解其中几个比较重要的函数。
1、boxoverlap.m
用来计算两个boxes中box间的重叠系数。元组o中的元素是矩阵,矩阵o{i}代表boxes a和box b(i)之间的交叉系数,size(o{i})=(m,1)。m–表示boxes a中有m个box。而size(o)=n。n–表示boxes b中有n个box,最后返回cell2mat(o),size为(m,n)
这个函数主要在选择产生的roi时会用到,用于选择满足一定重叠系数的roi.

function o = boxoverlap(a, b)
% Compute the symmetric intersection over union overlap between a set of
% bounding boxes in a and a single bounding box in b.
%
% a  a matrix where each row specifies a bounding box
% b  a matrix where each row specifies a bounding box
-------------------------------------------------------

o = cell(1, size(b, 1));
for i = 1:size(b, 1)
    x1 = max(a(:,1), b(i,1));%Create a matrix and return the largest value between each of its elements compared to a scalar.
    y1 = max(a(:,2), b(i,2));
    x2 = min(a(:,3), b(i,3));
    y2 = min(a(:,4), b(i,4));

    w = x2-x1+1;
    h = y2-y1+1;
    inter = w.*h;
    aarea = (a(:,3)-a(:,1)+1) .* (a(:,4)-a(:,2)+1);
    barea = (b(i,3)-b(i,1)+1) * (b(i,4)-b(i,2)+1);
    % intersection over union overlap
    o{i} = inter ./ (aarea+barea-inter);
    % set invalid entries to 0 overlap
    o{i}(w <= 0) = 0;
    o{i}(h <= 0) = 0;
end

o = cell2mat(o);

2、im_list_to_blob.m
输入元组ims,ims{i}为一张图片,将ims转换为blob(w,h,3,n)

function blob = im_list_to_blob(ims)%ims--
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值