utils.py 文件源码

python
阅读 46 收藏 0 点赞 0 评论 0

项目:DeepTextSpotter 作者: MichalBusta 项目源码 文件源码
def get_obox(im, scaled, box):

  image_size = (scaled.shape[1], scaled.shape[0])

  o_size = (im.shape[1], im.shape[0])
  scalex = o_size[0] / float(image_size[0])
  scaley = o_size[1] / float(image_size[1])

  box2 = np.copy(box)

  gtbox  = ((box[0][0], box[0][1]), (box[1][0], box[1][1]), box[2])
  gtbox = cv2.boxPoints(gtbox)
  gtbox = np.array(gtbox, dtype="float")

  #vis.draw_box_points(im,  np.array(gtbox, dtype="int"), color = (0, 255, 0))
  #cv2.imshow('orig', im)

  gtbox[:,0] /=  scalex
  gtbox[:,1] /=  scaley

  dh = gtbox[0, :] - gtbox[1, :]
  dw = gtbox[1, :] - gtbox[2, :]


  h = math.sqrt(dh[0] * dh[0] + dh[1] * dh[1])
  w = math.sqrt(dw[0] * dw[0] + dw[1] * dw[1])

  box2[0][0] /=  scalex
  box2[0][1] /=  scaley

  box2[1][0] = w
  box2[1][1] = h

  box2[2] = math.atan2((gtbox[2, 1] - gtbox[1, 1]), (gtbox[2, 0] - gtbox[1, 0])) * 180 / 3.14

  return box2
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号