docstr: Generate quadrangle.
docstr_tok: ["Generate","quadrangle","."]
code: def generate_quad(self, im_size, polys, tags):
      """
      Generate quadrangle.
      """
      h, w = im_size
      poly_mask = np.zeros((h, w), dtype=np.uint8)
      score_map = np.zeros((h, w), dtype=np.uint8)
      # (x1, y1, ..., x4, y4, short_edge_norm)
      geo_map = np.zeros((h, w, 9), dtype=np.float32)
      # mask used during traning, to ignore some hard areas
      training_mask = np.ones((h, w), dtype=np.uint8)
      for poly_idx, poly_tag in enumerate(zip(polys, tags)):
          poly = poly_tag[0]
          tag = poly_tag[1]
  
          r = [None, None, None, None]
          for i in range(4):
              dist1 = np.linalg.norm(poly[i] - poly[(i + 1) % 4])
              dist2 = np.linalg.norm(poly[i] - poly[(i - 1) % 4])
              r[i] = min(dist1, dist2)
          # score map
          shrinked_poly = self.shrink_poly(poly.copy(), r).astype(
              np.int32
          )[np.newaxis, :, :]
          cv2.fillPoly(score_map, shrinked_poly, 1)
          cv2.fillPoly(poly_mask, shrinked_poly, poly_idx + 1)
          # if the poly is too small, then ignore it during training
          poly_h = min(
              np.linalg.norm(poly[0] - poly[3]),
              np.linalg.norm(poly[1] - poly[2]),
          )
          poly_w = min(
              np.linalg.norm(poly[0] - poly[1]),
              np.linalg.norm(poly[2] - poly[3]),
          )
          if min(poly_h, poly_w) < self.min_text_size:
              cv2.fillPoly(
                  training_mask,
                  poly.astype(np.int32)[np.newaxis, :, :],
                  0,
              )
  
          if tag:
              cv2.fillPoly(
                  training_mask,
                  poly.astype(np.int32)[np.newaxis, :, :],
                  0,
              )
  
          xy_in_poly = np.argwhere(poly_mask == (poly_idx + 1))
          # geo map.
          y_in_poly = xy_in_poly[:, 0]
          x_in_poly = xy_in_poly[:, 1]
          poly[:, 0] = np.minimum(np.maximum(poly[:, 0], 0), w)
          poly[:, 1] = np.minimum(np.maximum(poly[:, 1], 0), h)
          for pno in range(4):
              geo_channel_beg = pno * 2
              geo_map[y_in_poly, x_in_poly, geo_channel_beg] = (
                  x_in_poly - poly[pno, 0]
              )
              geo_map[y_in_poly, x_in_poly, geo_channel_beg + 1] = (
                  y_in_poly - poly[pno, 1]
              )
          geo_map[y_in_poly, x_in_poly, 8] = 1.0 / max(
              min(poly_h, poly_w), 1.0
          )
      return score_map, geo_map, training_mask
  
file_path: PaddleOCR/ppocr/data/imaug/east_process.py
imports: import math
  import cv2
  import numpy
  import json
  import sys
  import os
label_desc: Use image node_id 8 for calling the EASTProcessTrain obj's underlying member method code with example usage: obj.generate_quad(im_size, polys, tags) and returns: score_map,  geo_map,  training_mask