def pixel_detect(score_map, geo_map, score_map_thresh=0.8, link_thresh=0.8):
'''
restore text boxes from score map and geo map
:param score_map:
:param geo_map:
:param timer:
:param score_map_thresh: threshhold for score map
:param box_thresh: threshhold for boxes
:param nms_thres: threshold for nms
:return:
'''
if len(score_map.shape) == 4:
score_map = score_map[0, :, :, 0]
geo_map = geo_map[0, :, :, ]
# filter the score map
res_map = np.zeros((score_map.shape[0] ,score_map.shape[1] ))
xy_text = np.argwhere(score_map > score_map_thresh)
for p in xy_text:
res_map[p[0], p[1]] = 1
res = res_map
for i in range(8):
geo_map_split = geo_map[:,:,i * 2 + 1]
link_text = np.argwhere(geo_map_split < link_thresh)
res[link_text[0], link_text[1]] = 0
return np.array(res_map, dtype=np.uint8)
评论列表
文章目录