docstr: Find the center point of poly as key_points, then fit and gather.
docstr_tok: ["Find","the","center","point","of","poly","as","key_points",",","then","fit","and","gather","."]
code: def fit_and_gather_tcl_points_v2(
      self,
      min_area_quad,
      poly,
      max_h,
      max_w,
      fixed_point_num=64,
      img_id=0,
      reference_height=3,
  ):
      """
      Find the center point of poly as key_points, then fit and gather.
      """
      key_point_xys = []
      point_num = poly.shape[0]
      for idx in range(point_num // 2):
          center_point = (poly[idx] + poly[point_num - 1 - idx]) / 2.0
          key_point_xys.append(center_point)
  
      tmp_image = np.zeros(
          shape=(
              max_h,
              max_w,
          ),
          dtype="float32",
      )
      cv2.polylines(
          tmp_image,
          [np.array(key_point_xys).astype("int32")],
          False,
          1.0,
      )
      ys, xs = np.where(tmp_image > 0)
      xy_text = np.array(list(zip(xs, ys)), dtype="float32")
  
      left_center_pt = (
          (min_area_quad[0] - min_area_quad[1]) / 2.0
      ).reshape(1, 2)
      right_center_pt = (
          (min_area_quad[1] - min_area_quad[2]) / 2.0
      ).reshape(1, 2)
      proj_unit_vec = (right_center_pt - left_center_pt) / (
          np.linalg.norm(right_center_pt - left_center_pt) + 1e-6
      )
      proj_unit_vec_tile = np.tile(
          proj_unit_vec, (xy_text.shape[0], 1)
      )  # (n, 2)
      left_center_pt_tile = np.tile(
          left_center_pt, (xy_text.shape[0], 1)
      )  # (n, 2)
      xy_text_to_left_center = xy_text - left_center_pt_tile
      proj_value = np.sum(
          xy_text_to_left_center * proj_unit_vec_tile, axis=1
      )
      xy_text = xy_text[np.argsort(proj_value)]
  
      # convert to np and keep the num of point not greater then fixed_point_num
      pos_info = np.array(xy_text).reshape(-1, 2)[:, ::-1]  # xy-> yx
      point_num = len(pos_info)
      if point_num > fixed_point_num:
          keep_ids = [
              int((point_num * 1.0 / fixed_point_num) * x)
              for x in range(fixed_point_num)
          ]
          pos_info = pos_info[keep_ids, :]
  
      keep = int(min(len(pos_info), fixed_point_num))
      if np.random.rand() < 0.2 and reference_height >= 3:
          dl = (np.random.rand(keep) - 0.5) * reference_height * 0.3
          random_float = np.array([1, 0]).reshape([1, 2]) * dl.reshape(
              [keep, 1]
          )
          pos_info += random_float
          pos_info[:, 0] = np.clip(pos_info[:, 0], 0, max_h - 1)
          pos_info[:, 1] = np.clip(pos_info[:, 1], 0, max_w - 1)
  
      # padding to fixed length
      pos_l = np.zeros((self.tcl_len, 3), dtype=np.int32)
      pos_l[:, 0] = np.ones((self.tcl_len,)) * img_id
      pos_m = np.zeros((self.tcl_len, 1), dtype=np.float32)
      pos_l[:keep, 1:] = np.round(pos_info).astype(np.int32)
      pos_m[:keep] = 1.0
      return pos_l, pos_m
  
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 7 for calling the PGProcessTrain obj's underlying member method code with example usage: obj.fit_and_gather_tcl_points_v2(min_area_quad, poly, max_h, max_w, fixed_point_num, img_id, reference_height) and returns: pos_l,  pos_m