docstr: Generate min area quad from poly.
docstr_tok: ["Generate","min","area","quad","from","poly","."]
code: def gen_quad_from_poly(self, poly):
      """
      Generate min area quad from poly.
      """
      point_num = poly.shape[0]
      min_area_quad = np.zeros((4, 2), dtype=np.float32)
      rect = cv2.minAreaRect(
          poly.astype(np.int32)
      )  # (center (x,y), (width, height), angle of rotation)
      box = np.array(cv2.boxPoints(rect))
  
      first_point_idx = 0
      min_dist = 1e4
      for i in range(4):
          dist = (
              np.linalg.norm(box[(i + 0) % 4] - poly[0])
              + np.linalg.norm(
                  box[(i + 1) % 4] - poly[point_num // 2 - 1]
              )
              + np.linalg.norm(box[(i + 2) % 4] - poly[point_num // 2])
              + np.linalg.norm(box[(i + 3) % 4] - poly[-1])
          )
          if dist < min_dist:
              min_dist = dist
              first_point_idx = i
      for i in range(4):
          min_area_quad[i] = box[(first_point_idx + i) % 4]
  
      return min_area_quad
  
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 4 for calling the PGProcessTrain obj's underlying member method code with example usage: obj.gen_quad_from_poly(poly) and returns: min_area_quad