parameters: (self,
                               hw,
                               polys,
                               tags,
                               tcl_ratio=0.3,
                               ds_ratio=0.25)
return_statement: return tvo_map, tco_map
docstring: Generate tcl map, tvo map and tbo map.
docstring_summary: Generate tcl map, tvo map and tbo map.
docstring_tokens: Generate tcl map tvo map and tbo map .
function: def generate_tvo_and_tco(self,
                               hw,
                               polys,
                               tags,
                               tcl_ratio=0.3,
                               ds_ratio=0.25):
          """
          Generate tcl map, tvo map and tbo map.
          """
          h, w = hw
          h, w = int(h * ds_ratio), int(w * ds_ratio)
          polys = polys * ds_ratio
          poly_mask = np.zeros((h, w), dtype=np.float32)
  
          tvo_map = np.ones((9, h, w), dtype=np.float32)
          tvo_map[0:-1:2] = np.tile(np.arange(0, w), (h, 1))
          tvo_map[1:-1:2] = np.tile(np.arange(0, w), (h, 1)).T
          poly_tv_xy_map = np.zeros((8, h, w), dtype=np.float32)
  
          # tco map
          tco_map = np.ones((3, h, w), dtype=np.float32)
          tco_map[0] = np.tile(np.arange(0, w), (h, 1))
          tco_map[1] = np.tile(np.arange(0, w), (h, 1)).T
          poly_tc_xy_map = np.zeros((2, h, w), dtype=np.float32)
  
          poly_short_edge_map = np.ones((h, w), dtype=np.float32)
  
          for poly, poly_tag in zip(polys, tags):
  
              if poly_tag == True:
                  continue
  
              # adjust point order for vertical poly
              poly = self.adjust_point(poly)
  
              # generate min_area_quad
              min_area_quad, center_point = self.gen_min_area_quad_from_poly(poly)
              min_area_quad_h = 0.5 * (
                  np.linalg.norm(min_area_quad[0] - min_area_quad[3]) +
                  np.linalg.norm(min_area_quad[1] - min_area_quad[2]))
              min_area_quad_w = 0.5 * (
                  np.linalg.norm(min_area_quad[0] - min_area_quad[1]) +
                  np.linalg.norm(min_area_quad[2] - min_area_quad[3]))
  
              # generate tcl map and text, 128 * 128
              tcl_poly = self.poly2tcl(poly, tcl_ratio)
  
              # generate poly_tv_xy_map
              for idx in range(4):
                  cv2.fillPoly(
                      poly_tv_xy_map[2 * idx],
                      np.round(tcl_poly[np.newaxis, :, :]).astype(np.int32),
                      float(min(max(min_area_quad[idx, 0], 0), w)))
                  cv2.fillPoly(
                      poly_tv_xy_map[2 * idx + 1],
                      np.round(tcl_poly[np.newaxis, :, :]).astype(np.int32),
                      float(min(max(min_area_quad[idx, 1], 0), h)))
  
              # generate poly_tc_xy_map
              for idx in range(2):
                  cv2.fillPoly(
                      poly_tc_xy_map[idx],
                      np.round(tcl_poly[np.newaxis, :, :]).astype(np.int32),
                      float(center_point[idx]))
  
              # generate poly_short_edge_map
              cv2.fillPoly(
                  poly_short_edge_map,
                  np.round(tcl_poly[np.newaxis, :, :]).astype(np.int32),
                  float(max(min(min_area_quad_h, min_area_quad_w), 1.0)))
  
              # generate poly_mask and training_mask
              cv2.fillPoly(poly_mask,
                           np.round(tcl_poly[np.newaxis, :, :]).astype(np.int32),
                           1)
  
          tvo_map *= poly_mask
          tvo_map[:8] -= poly_tv_xy_map
          tvo_map[-1] /= poly_short_edge_map
          tvo_map = tvo_map.transpose((1, 2, 0))
  
          tco_map *= poly_mask
          tco_map[:2] -= poly_tc_xy_map
          tco_map[-1] /= poly_short_edge_map
          tco_map = tco_map.transpose((1, 2, 0))
  
          return tvo_map, tco_map
function_tokens: def generate_tvo_and_tco ( self , hw , polys , tags , tcl_ratio = 0.3 , ds_ratio = 0.25 ) : h , w = hw h , w = int ( h * ds_ratio ) , int ( w * ds_ratio ) polys = polys * ds_ratio poly_mask = np . zeros ( ( h , w ) , dtype = np . float32 ) tvo_map = np . ones ( ( 9 , h , w ) , dtype = np . float32 ) tvo_map [ 0 : - 1 : 2 ] = np . tile ( np . arange ( 0 , w ) , ( h , 1 ) ) tvo_map [ 1 : - 1 : 2 ] = np . tile ( np . arange ( 0 , w ) , ( h , 1 ) ) . T poly_tv_xy_map = np . zeros ( ( 8 , h , w ) , dtype = np . float32 ) # tco map tco_map = np . ones ( ( 3 , h , w ) , dtype = np . float32 ) tco_map [ 0 ] = np . tile ( np . arange ( 0 , w ) , ( h , 1 ) ) tco_map [ 1 ] = np . tile ( np . arange ( 0 , w ) , ( h , 1 ) ) . T poly_tc_xy_map = np . zeros ( ( 2 , h , w ) , dtype = np . float32 ) poly_short_edge_map = np . ones ( ( h , w ) , dtype = np . float32 ) for poly , poly_tag in zip ( polys , tags ) : if poly_tag == True : continue # adjust point order for vertical poly poly = self . adjust_point ( poly ) # generate min_area_quad min_area_quad , center_point = self . gen_min_area_quad_from_poly ( poly ) min_area_quad_h = 0.5 * ( np . linalg . norm ( min_area_quad [ 0 ] - min_area_quad [ 3 ] ) + np . linalg . norm ( min_area_quad [ 1 ] - min_area_quad [ 2 ] ) ) min_area_quad_w = 0.5 * ( np . linalg . norm ( min_area_quad [ 0 ] - min_area_quad [ 1 ] ) + np . linalg . norm ( min_area_quad [ 2 ] - min_area_quad [ 3 ] ) ) # generate tcl map and text, 128 * 128 tcl_poly = self . poly2tcl ( poly , tcl_ratio ) # generate poly_tv_xy_map for idx in range ( 4 ) : cv2 . fillPoly ( poly_tv_xy_map [ 2 * idx ] , np . round ( tcl_poly [ np . newaxis , : , : ] ) . astype ( np . int32 ) , float ( min ( max ( min_area_quad [ idx , 0 ] , 0 ) , w ) ) ) cv2 . fillPoly ( poly_tv_xy_map [ 2 * idx + 1 ] , np . round ( tcl_poly [ np . newaxis , : , : ] ) . astype ( np . int32 ) , float ( min ( max ( min_area_quad [ idx , 1 ] , 0 ) , h ) ) ) # generate poly_tc_xy_map for idx in range ( 2 ) : cv2 . fillPoly ( poly_tc_xy_map [ idx ] , np . round ( tcl_poly [ np . newaxis , : , : ] ) . astype ( np . int32 ) , float ( center_point [ idx ] ) ) # generate poly_short_edge_map cv2 . fillPoly ( poly_short_edge_map , np . round ( tcl_poly [ np . newaxis , : , : ] ) . astype ( np . int32 ) , float ( max ( min ( min_area_quad_h , min_area_quad_w ) , 1.0 ) ) ) # generate poly_mask and training_mask cv2 . fillPoly ( poly_mask , np . round ( tcl_poly [ np . newaxis , : , : ] ) . astype ( np . int32 ) , 1 ) tvo_map *= poly_mask tvo_map [ : 8 ] -= poly_tv_xy_map tvo_map [ - 1 ] /= poly_short_edge_map tvo_map = tvo_map . transpose ( ( 1 , 2 , 0 ) ) tco_map *= poly_mask tco_map [ : 2 ] -= poly_tc_xy_map tco_map [ - 1 ] /= poly_short_edge_map tco_map = tco_map . transpose ( ( 1 , 2 , 0 ) ) return tvo_map , tco_map