parameters: (seg_maps, timer, image_w, image_h, min_area_thresh=10, seg_map_thresh=0.9, ratio = 1)
return_statement: return np.array(boxes), kernals, timer
docstring: restore text boxes from score map and geo map
      :param seg_maps:
      :param timer:
      :param min_area_thresh:
      :param seg_map_thresh: threshhold for seg map
      :param ratio: compute each seg map thresh
      :return:
docstring_summary: restore text boxes from score map and geo map
      :param seg_maps:
      :param timer:
      :param min_area_thresh:
      :param seg_map_thresh: threshhold for seg map
      :param ratio: compute each seg map thresh
      :return:
docstring_tokens: restore text boxes from score map and geo map : param seg_maps : : param timer : : param min_area_thresh : : param seg_map_thresh : threshhold for seg map : param ratio : compute each seg map thresh : return :
function: def detect(seg_maps, timer, image_w, image_h, min_area_thresh=10, seg_map_thresh=0.9, ratio = 1):
      '''
      restore text boxes from score map and geo map
      :param seg_maps:
      :param timer:
      :param min_area_thresh:
      :param seg_map_thresh: threshhold for seg map
      :param ratio: compute each seg map thresh
      :return:
      '''
      if len(seg_maps.shape) == 4:
          seg_maps = seg_maps[0, :, :, ]
      #get kernals, sequence: 0->n, max -> min
      kernals = []
      one = np.ones_like(seg_maps[..., 0], dtype=np.uint8)
      zero = np.zeros_like(seg_maps[..., 0], dtype=np.uint8)
      thresh = seg_map_thresh
      for i in range(seg_maps.shape[-1]-1, -1, -1):
          kernal = np.where(seg_maps[..., i]>thresh, one, zero)
          kernals.append(kernal)
          thresh = seg_map_thresh*ratio
      start = time.time()
      mask_res, label_values = pse(kernals, min_area_thresh)
      timer['pse'] = time.time()-start
      mask_res = np.array(mask_res)
      mask_res_resized = cv2.resize(mask_res, (image_w, image_h), interpolation=cv2.INTER_NEAREST)
      boxes = []
      for label_value in label_values:
          #(y,x)
          points = np.argwhere(mask_res_resized==label_value)
          points = points[:, (1,0)]
          rect = cv2.minAreaRect(points)
          box = cv2.boxPoints(rect)
          boxes.append(box)
  
      return np.array(boxes), kernals, timer
function_tokens: def detect ( seg_maps , timer , image_w , image_h , min_area_thresh = 10 , seg_map_thresh = 0.9 , ratio = 1 ) : if len ( seg_maps . shape ) == 4 : seg_maps = seg_maps [ 0 , : , : , ] #get kernals, sequence: 0->n, max -> min kernals = [ ] one = np . ones_like ( seg_maps [ ... , 0 ] , dtype = np . uint8 ) zero = np . zeros_like ( seg_maps [ ... , 0 ] , dtype = np . uint8 ) thresh = seg_map_thresh for i in range ( seg_maps . shape [ - 1 ] - 1 , - 1 , - 1 ) : kernal = np . where ( seg_maps [ ... , i ] > thresh , one , zero ) kernals . append ( kernal ) thresh = seg_map_thresh * ratio start = time . time ( ) mask_res , label_values = pse ( kernals , min_area_thresh ) timer [ 'pse' ] = time . time ( ) - start mask_res = np . array ( mask_res ) mask_res_resized = cv2 . resize ( mask_res , ( image_w , image_h ) , interpolation = cv2 . INTER_NEAREST ) boxes = [ ] for label_value in label_values : #(y,x) points = np . argwhere ( mask_res_resized == label_value ) points = points [ : , ( 1 , 0 ) ] rect = cv2 . minAreaRect ( points ) box = cv2 . boxPoints ( rect ) boxes . append ( box ) return np . array ( boxes ) , kernals , timer