docstr_tok: []
code: def generate_direction_map(self, poly_quads, n_char, direction_map):
      """ """
      width_list = []
      height_list = []
      for quad in poly_quads:
          quad_w = (
              np.linalg.norm(quad[0] - quad[1])
              + np.linalg.norm(quad[2] - quad[3])
          ) / 2.0
          quad_h = (
              np.linalg.norm(quad[0] - quad[3])
              + np.linalg.norm(quad[2] - quad[1])
          ) / 2.0
          width_list.append(quad_w)
          height_list.append(quad_h)
      norm_width = max(sum(width_list) / n_char, 1.0)
      average_height = max(sum(height_list) / len(height_list), 1.0)
      k = 1
      for quad in poly_quads:
          direct_vector_full = (
              (quad[1] + quad[2]) - (quad[0] + quad[3])
          ) / 2.0
          direct_vector = (
              direct_vector_full
              / (np.linalg.norm(direct_vector_full) + 1e-6)
              * norm_width
          )
          direction_label = tuple(
              map(
                  float,
                  [
                      direct_vector[0],
                      direct_vector[1],
                      1.0 / average_height,
                  ],
              )
          )
          cv2.fillPoly(
              direction_map,
              quad.round().astype(np.int32)[np.newaxis, :, :],
              direction_label,
          )
          k += 1
      return direction_map
  
imports: import math
  import cv2
  import numpy
  from skimage.morphology._skeletonize import thin
  from ppocr.utils.e2e_utils.extract_textpoint_fast import sort_and_expand_with_direction_v2
label_desc: Use image node_id 9 for calling the PGProcessTrain obj's underlying member method code with example usage: obj.generate_direction_map(poly_quads, n_char, direction_map) and returns: direction_map