阅读MatconvNet中Fast Rcnn源码笔记(1)

bbox_function文件下的m代码:

bbox_clip文件:boxes = bbox_clip(boxes, im_size);剪切边检框;

bbox_nms文件:pick = bbox_nms(boxes, overlap);非极大抑制。消除多余的交叉重读边检框,可以参考非极大抑制的原理,便于更好理解;

bbox_draw文件:im = bbox_draw(im,boxes,c,t);画目标框;

bbox_overlap文件:overlaps = bbox_overlap(boxes1,boxes2);记录一组框与另一组每个框的IOU(交并集)的比例大小;

bbox_scale文件:缩放边界框,注意里面的一个计算:

function boxOut = bbox_scale2(boxIn,scale,szOut)

if isempty(boxIn), boxOut = []; return; end

boxOut = scale * (boxIn-1) + 1;

boxOut = [max(1,round(boxOut(:,1))),...
  max(1,round(boxOut(:,2))),...
  min(szOut(1),round(boxOut(:,3))),...
  min(szOut(2),round(boxOut(:,4)))];

这里boxIn-1的作用是,得到边检框宽高,放缩之后再加上1,就得到了放缩之后的边界框坐标。

例如:

(x1, y1, x2, y2)=(1, 1, 2, 2,),若不减一直接放大3倍之后的坐标(3,3, 6, 6);但是先减一,再放缩,之后再加上1的坐标为(1, 1, 3, 3)放缩之后的框的大小一样,但是坐标不一样了。前者是缩放的坐标,而后者是真正缩放的目标框的大小。

bbox_transform文件:targets = bbox_transform(ex_rois, gt_rois);

bbox_transform_inv文件:pred_boxes = bbox_transform_inv(boxes, deltas);

bbox_remove_duplicates文件:bboxeso = bbox_remove_duplicates(bboxes, minSize, maxNum);删除重复边界框以及过于太小的目标框,并且限制目标框的数目。

function bboxeso = bbox_remove_duplicates(bboxes, minSize, maxNum)
% Copyright (C) 2016 Hakan Bilen.
% All rights reserved.
%
% This file is part of the VLFeat library and is made available under
% the terms of the BSD license (see the COPYING file).
bboxeso = cell(size(bboxes));
for i=1:numel(bboxes)
  bbox = bboxes{i};
  % remove small bbox
  isGood = (bbox(:,3)>=bbox(:,1)-1+minSize) & (bbox(:,4)>=bbox(:,2)-1+minSize);
  bbox = bbox(isGood,:);
  % remove duplicate ones
  [dummy, uniqueIdx] = unique(bbox, 'rows', 'first');
  uniqueIdx = sort(uniqueIdx);
  bbox = bbox(uniqueIdx,:);
  % limit number for training
  nB = min(size(bbox,1),maxNum);

  bboxeso{i} = bbox(1:nB,:);
end

你可能感兴趣的:(深度学习,ObjectDetection,MatconvNet)