docstr: Generate polygon.
docstr_tok: ["Generate","polygon","."]
code: def generate_tcl_label(
      self,
      hw,
      polys,
      tags,
      ds_ratio,
      tcl_ratio=0.3,
      shrink_ratio_of_width=0.15,
  ):
      """
      Generate polygon.
      """
      h, w = hw
      h, w = int(h * ds_ratio), int(w * ds_ratio)
      polys = polys * ds_ratio
  
      score_map = np.zeros(
          (
              h,
              w,
          ),
          dtype=np.float32,
      )
      tbo_map = np.zeros((h, w, 5), dtype=np.float32)
      training_mask = np.ones(
          (
              h,
              w,
          ),
          dtype=np.float32,
      )
      direction_map = np.ones((h, w, 3)) * np.array([0, 0, 1]).reshape(
          [1, 1, 3]
      ).astype(np.float32)
  
      for poly_idx, poly_tag in enumerate(zip(polys, tags)):
          poly = poly_tag[0]
          tag = poly_tag[1]
  
          # 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])
          )
  
          if (
              min(min_area_quad_h, min_area_quad_w)
              < self.min_text_size * ds_ratio
              or min(min_area_quad_h, min_area_quad_w)
              > self.max_text_size * ds_ratio
          ):
              continue
  
          if tag:
              # continue
              cv2.fillPoly(
                  training_mask,
                  poly.astype(np.int32)[np.newaxis, :, :],
                  0.15,
              )
          else:
              tcl_poly = self.poly2tcl(poly, tcl_ratio)
              tcl_quads = self.poly2quads(tcl_poly)
              poly_quads = self.poly2quads(poly)
              # stcl map
              stcl_quads, quad_index = self.shrink_poly_along_width(
                  tcl_quads,
                  shrink_ratio_of_width=shrink_ratio_of_width,
                  expand_height_ratio=1.0 / tcl_ratio,
              )
              # generate tcl map
              cv2.fillPoly(
                  score_map, np.round(stcl_quads).astype(np.int32), 1.0
              )
  
              # generate tbo map
              for idx, quad in enumerate(stcl_quads):
                  quad_mask = np.zeros((h, w), dtype=np.float32)
                  quad_mask = cv2.fillPoly(
                      quad_mask,
                      np.round(quad[np.newaxis, :, :]).astype(np.int32),
                      1.0,
                  )
                  tbo_map = self.gen_quad_tbo(
                      poly_quads[quad_index[idx]], quad_mask, tbo_map
                  )
      return score_map, tbo_map, training_mask
  
imports: import math
  import cv2
  import numpy
  import json
  import sys
  import os
label_desc: Use image node_id 8 for calling the SASTProcessTrain obj's underlying member method code with example usage: obj.generate_tcl_label(hw, polys, tags, ds_ratio, tcl_ratio, shrink_ratio_of_width) and returns: score_map,  tbo_map,  training_mask