parameters: (self, im: np.ndarray, text_polys: np.ndarray, input_size)
return_statement: return im, text_polys
docstring: 从图片中裁剪出 cropsize大小的图片和对应区域的文本框
          :param im: 图片
          :param text_polys: 文本框
          :param input_size: 输出图像大小
          :return: 裁剪后的图片和文本框
docstring_summary: 从图片中裁剪出 cropsize大小的图片和对应区域的文本框
          :param im: 图片
          :param text_polys: 文本框
          :param input_size: 输出图像大小
          :return: 裁剪后的图片和文本框
docstring_tokens: 从图片中裁剪出 cropsize大小的图片和对应区域的文本框 : param im : 图片 : param text_polys : 文本框 : param input_size : 输出图像大小 : return : 裁剪后的图片和文本框
function: def random_crop_image_pse(self, im: np.ndarray, text_polys: np.ndarray, input_size) -> tuple:
          """
          从图片中裁剪出 cropsize大小的图片和对应区域的文本框
          :param im: 图片
          :param text_polys: 文本框
          :param input_size: 输出图像大小
          :return: 裁剪后的图片和文本框
          """
          h, w, _ = im.shape
          short_edge = min(h, w)
          if short_edge < input_size:
              # 保证短边 >= inputsize
              scale = input_size / short_edge
              im = cv2.resize(im, dsize=None, fx=scale, fy=scale)
              text_polys *= scale
              h, w, _ = im.shape
          # 计算随机范围
          w_range = w - input_size
          h_range = h - input_size
          for _ in range(50):
              xmin = random.randint(0, w_range)
              ymin = random.randint(0, h_range)
              xmax = xmin + input_size
              ymax = ymin + input_size
              if text_polys.shape[0] != 0:
                  selected_polys = []
                  for poly in text_polys:
                      if poly[:, 0].max() < xmin or poly[:, 0].min() > xmax or \
                              poly[:, 1].max() < ymin or poly[:, 1].min() > ymax:
                          continue
                      # area_p = cv2.contourArea(poly)
                      poly[:, 0] -= xmin
                      poly[:, 1] -= ymin
                      poly[:, 0] = np.clip(poly[:, 0], 0, input_size)
                      poly[:, 1] = np.clip(poly[:, 1], 0, input_size)
                      # rect = cv2.minAreaRect(poly)
                      # area_n = cv2.contourArea(poly)
                      # h1, w1 = rect[1]
                      # if w1 < 10 or h1 < 10 or area_n / area_p < 0.5:
                      #     continue
                      selected_polys.append(poly)
              else:
                  selected_polys = []
              # if len(selected_polys) == 0:
                  # 区域内没有文本
                  # continue
              im = im[ymin:ymax, xmin:xmax, :]
              polys = np.array(selected_polys)
              return im, polys
          return im, text_polys
function_tokens: def random_crop_image_pse ( self , im : np . ndarray , text_polys : np . ndarray , input_size ) -> tuple : h , w , _ = im . shape short_edge = min ( h , w ) if short_edge < input_size : # 保证短边 >= inputsize scale = input_size / short_edge im = cv2 . resize ( im , dsize = None , fx = scale , fy = scale ) text_polys *= scale h , w , _ = im . shape # 计算随机范围 w_range = w - input_size h_range = h - input_size for _ in range ( 50 ) : xmin = random . randint ( 0 , w_range ) ymin = random . randint ( 0 , h_range ) xmax = xmin + input_size ymax = ymin + input_size if text_polys . shape [ 0 ] != 0 : selected_polys = [ ] for poly in text_polys : if poly [ : , 0 ] . max ( ) < xmin or poly [ : , 0 ] . min ( ) > xmax or poly [ : , 1 ] . max ( ) < ymin or poly [ : , 1 ] . min ( ) > ymax : continue # area_p = cv2.contourArea(poly) poly [ : , 0 ] -= xmin poly [ : , 1 ] -= ymin poly [ : , 0 ] = np . clip ( poly [ : , 0 ] , 0 , input_size ) poly [ : , 1 ] = np . clip ( poly [ : , 1 ] , 0 , input_size ) # rect = cv2.minAreaRect(poly) # area_n = cv2.contourArea(poly) # h1, w1 = rect[1] # if w1 < 10 or h1 < 10 or area_n / area_p < 0.5: #     continue selected_polys . append ( poly ) else : selected_polys = [ ] # if len(selected_polys) == 0: # 区域内没有文本 # continue im = im [ ymin : ymax , xmin : xmax , : ] polys = np . array ( selected_polys ) return im , polys return im , text_polys