parameters: (self, im, text_polys)
return_statement: return dst_im, dst_polys
docstring: rotate image with 90 / 180 / 270 degre
docstring_summary: rotate image with 90 / 180 / 270 degre
docstring_tokens: rotate image with 90 / 180 / 270 degre
function: def rotate_im_poly(self, im, text_polys):
          """
          rotate image with 90 / 180 / 270 degre
          """
          im_w, im_h = im.shape[1], im.shape[0]
          dst_im = im.copy()
          dst_polys = []
          rand_degree_ratio = np.random.rand()
          rand_degree_cnt = 1
          if 0.333 < rand_degree_ratio < 0.666:
              rand_degree_cnt = 2
          elif rand_degree_ratio > 0.666:
              rand_degree_cnt = 3
          for i in range(rand_degree_cnt):
              dst_im = np.rot90(dst_im)
          rot_degree = -90 * rand_degree_cnt
          rot_angle = rot_degree * math.pi / 180.0
          n_poly = text_polys.shape[0]
          cx, cy = 0.5 * im_w, 0.5 * im_h
          ncx, ncy = 0.5 * dst_im.shape[1], 0.5 * dst_im.shape[0]
          for i in range(n_poly):
              wordBB = text_polys[i]
              poly = []
              for j in range(4):
                  sx, sy = wordBB[j][0], wordBB[j][1]
                  dx = math.cos(rot_angle) * (sx - cx)\
                      - math.sin(rot_angle) * (sy - cy) + ncx
                  dy = math.sin(rot_angle) * (sx - cx)\
                      + math.cos(rot_angle) * (sy - cy) + ncy
                  poly.append([dx, dy])
              dst_polys.append(poly)
          dst_polys = np.array(dst_polys, dtype=np.float32)
          return dst_im, dst_polys
function_tokens: def rotate_im_poly ( self , im , text_polys ) : im_w , im_h = im . shape [ 1 ] , im . shape [ 0 ] dst_im = im . copy ( ) dst_polys = [ ] rand_degree_ratio = np . random . rand ( ) rand_degree_cnt = 1 if 0.333 < rand_degree_ratio < 0.666 : rand_degree_cnt = 2 elif rand_degree_ratio > 0.666 : rand_degree_cnt = 3 for i in range ( rand_degree_cnt ) : dst_im = np . rot90 ( dst_im ) rot_degree = - 90 * rand_degree_cnt rot_angle = rot_degree * math . pi / 180.0 n_poly = text_polys . shape [ 0 ] cx , cy = 0.5 * im_w , 0.5 * im_h ncx , ncy = 0.5 * dst_im . shape [ 1 ] , 0.5 * dst_im . shape [ 0 ] for i in range ( n_poly ) : wordBB = text_polys [ i ] poly = [ ] for j in range ( 4 ) : sx , sy = wordBB [ j ] [ 0 ] , wordBB [ j ] [ 1 ] dx = math . cos ( rot_angle ) * ( sx - cx ) - math . sin ( rot_angle ) * ( sy - cy ) + ncx dy = math . sin ( rot_angle ) * ( sx - cx ) + math . cos ( rot_angle ) * ( sy - cy ) + ncy poly . append ( [ dx , dy ] ) dst_polys . append ( poly ) dst_polys = np . array ( dst_polys , dtype = np . float32 ) return dst_im , dst_polys