docstr: fit a poly inside the origin poly, maybe bugs here...
  used for generate the score map
  :param poly: the text poly
  :param r: r in the paper
  :return: the shrinked poly
docstr_tok: ["fit","a","poly","inside","the","origin","poly",",","maybe","bugs","here","...","used","for","generate","the","score","map",":","param","poly",":","the","text","poly",":","param","r",":","r","in","the","paper",":","return",":","the","shrinked","poly"]
code: def shrink_poly(self, poly, r):
      """
      fit a poly inside the origin poly, maybe bugs here...
      used for generate the score map
      :param poly: the text poly
      :param r: r in the paper
      :return: the shrinked poly
      """
      # shrink ratio
      R = 0.3
      # find the longer pair
      dist0 = np.linalg.norm(poly[0] - poly[1])
      dist1 = np.linalg.norm(poly[2] - poly[3])
      dist2 = np.linalg.norm(poly[0] - poly[3])
      dist3 = np.linalg.norm(poly[1] - poly[2])
      if dist0 + dist1 > dist2 + dist3:
          # first move (p0, p1), (p2, p3), then (p0, p3), (p1, p2)
          ## p0, p1
          theta = np.arctan2(
              (poly[1][1] - poly[0][1]), (poly[1][0] - poly[0][0])
          )
          poly[0][0] += R * r[0] * np.cos(theta)
          poly[0][1] += R * r[0] * np.sin(theta)
          poly[1][0] -= R * r[1] * np.cos(theta)
          poly[1][1] -= R * r[1] * np.sin(theta)
          ## p2, p3
          theta = np.arctan2(
              (poly[2][1] - poly[3][1]), (poly[2][0] - poly[3][0])
          )
          poly[3][0] += R * r[3] * np.cos(theta)
          poly[3][1] += R * r[3] * np.sin(theta)
          poly[2][0] -= R * r[2] * np.cos(theta)
          poly[2][1] -= R * r[2] * np.sin(theta)
          ## p0, p3
          theta = np.arctan2(
              (poly[3][0] - poly[0][0]), (poly[3][1] - poly[0][1])
          )
          poly[0][0] += R * r[0] * np.sin(theta)
          poly[0][1] += R * r[0] * np.cos(theta)
          poly[3][0] -= R * r[3] * np.sin(theta)
          poly[3][1] -= R * r[3] * np.cos(theta)
          ## p1, p2
          theta = np.arctan2(
              (poly[2][0] - poly[1][0]), (poly[2][1] - poly[1][1])
          )
          poly[1][0] += R * r[1] * np.sin(theta)
          poly[1][1] += R * r[1] * np.cos(theta)
          poly[2][0] -= R * r[2] * np.sin(theta)
          poly[2][1] -= R * r[2] * np.cos(theta)
      else:
          ## p0, p3
          # print poly
          theta = np.arctan2(
              (poly[3][0] - poly[0][0]), (poly[3][1] - poly[0][1])
          )
          poly[0][0] += R * r[0] * np.sin(theta)
          poly[0][1] += R * r[0] * np.cos(theta)
          poly[3][0] -= R * r[3] * np.sin(theta)
          poly[3][1] -= R * r[3] * np.cos(theta)
          ## p1, p2
          theta = np.arctan2(
              (poly[2][0] - poly[1][0]), (poly[2][1] - poly[1][1])
          )
          poly[1][0] += R * r[1] * np.sin(theta)
          poly[1][1] += R * r[1] * np.cos(theta)
          poly[2][0] -= R * r[2] * np.sin(theta)
          poly[2][1] -= R * r[2] * np.cos(theta)
          ## p0, p1
          theta = np.arctan2(
              (poly[1][1] - poly[0][1]), (poly[1][0] - poly[0][0])
          )
          poly[0][0] += R * r[0] * np.cos(theta)
          poly[0][1] += R * r[0] * np.sin(theta)
          poly[1][0] -= R * r[1] * np.cos(theta)
          poly[1][1] -= R * r[1] * np.sin(theta)
          ## p2, p3
          theta = np.arctan2(
              (poly[2][1] - poly[3][1]), (poly[2][0] - poly[3][0])
          )
          poly[3][0] += R * r[3] * np.cos(theta)
          poly[3][1] += R * r[3] * np.sin(theta)
          poly[2][0] -= R * r[2] * np.cos(theta)
          poly[2][1] -= R * r[2] * np.sin(theta)
      return poly
  
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 7 for calling the EASTProcessTrain obj's underlying member method code with example usage: obj.shrink_poly(poly, r) and returns: poly