def generate_bboxes(scores_map, reg, scale, t):
stride = 2
cellsize = 12
(y, x) = np.where(scores_map >= t)
if len(y) < 1:
return None
scores = scores_map[y, x]
dx1, dy1, dx2, dy2 = [reg[i, y, x] for i in range(4)]
reg = np.array([dx1, dy1, dx2, dy2])
bbox = np.array([y, x])
# bb1 = np.fix((stride * bbox) / scale)
# bb2 = np.fix((stride * bbox + cellsize) / scale)
# !!! Use fix() for top-left point, and round() for bottom-right point
# !!! So we can cover a 'whole' face !!! added by zhaoyafei 2017-07-18
bb1 = np.fix((stride * bbox) / scale)
bb2 = np.round((stride * bbox + cellsize) / scale)
# print 'bb1.shape:', bb1.shape
# print 'bb2.shape:', bb2.shape
# print 'scores.shape:', scores.shape
# print 'reg.shape:', reg.shape
bbox_out = np.vstack((bb1, bb2, scores, reg))
# print 'bbox_out.shape:', bbox_out.shape
return bbox_out.T
评论列表
文章目录