faster rcnn generate_anchors 源码理解

这里比较trick的就是_ratio_enum了,这里是要生成面积一样下,高宽比=0.5, 1, 2的所有矩形。

x是宽,x * x * 0.5 = area => x * x = area * 2

def _ratio_enum(anchor, ratios):
   """
   Enumerate a set of anchors for each aspect ratio wrt an anchor.
   """

   w, h, x_ctr, y_ctr = _whctrs(anchor)
   size = w * h
   size_ratios = size / ratios
   ws = np.round(np.sqrt(size_ratios))
   hs = np.round(ws * ratios)
   anchors = _mkanchors(ws, hs, x_ctr, y_ctr)
   return anchors

版权声明:本文为u013200703原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。