(self, data: dict)
return data
从scales中随机选择一个尺度，对图片和文本框进行缩放
        :param data: {'img':,'text_polys':,'texts':,'ignore_tags':}
        :return:
从scales中随机选择一个尺度，对图片和文本框进行缩放
        :param data: {'img':,'text_polys':,'texts':,'ignore_tags':}
        :return:
从scales中随机选择一个尺度，对图片和文本框进行缩放 : param data : { img : text_polys : texts : ignore_tags : } : return :
def __call__(self, data: dict) -> dict:
        """
        从scales中随机选择一个尺度，对图片和文本框进行缩放
        :param data: {'img':,'text_polys':,'texts':,'ignore_tags':}
        :return:
        """
        im = data['img']
        text_polys = data['text_polys']
        ignore_tags = data['ignore_tags']
        texts = data['texts']
        all_care_polys = [text_polys[i] for i, tag in enumerate(ignore_tags) if not tag]
        # 计算crop区域
        crop_x, crop_y, crop_w, crop_h = self.crop_area(im, all_care_polys)
        # crop 图片 保持比例填充
        scale_w = self.size[0] / crop_w
        scale_h = self.size[1] / crop_h
        scale = min(scale_w, scale_h)
        h = int(crop_h * scale)
        w = int(crop_w * scale)
        if self.keep_ratio:
            if len(im.shape) == 3:
                padimg = np.zeros((self.size[1], self.size[0], im.shape[2]), im.dtype)
            else:
                padimg = np.zeros((self.size[1], self.size[0]), im.dtype)
            padimg[:h, :w] = cv2.resize(im[crop_y:crop_y + crop_h, crop_x:crop_x + crop_w], (w, h))
            img = padimg
        else:
            img = cv2.resize(im[crop_y:crop_y + crop_h, crop_x:crop_x + crop_w], tuple(self.size))
        # crop 文本框
        text_polys_crop = []
        ignore_tags_crop = []
        texts_crop = []
        for poly, text, tag in zip(text_polys, texts, ignore_tags):
            poly = ((poly - (crop_x, crop_y)) * scale).tolist()
            if not self.is_poly_outside_rect(poly, 0, 0, w, h):
                text_polys_crop.append(poly)
                ignore_tags_crop.append(tag)
                texts_crop.append(text)
        data['img'] = img
        data['text_polys'] = np.float32(text_polys_crop)
        data['ignore_tags'] = ignore_tags_crop
        data['texts'] = texts_crop
        return data
def __call__ ( self , data : dict ) -> dict : im = data [ 'img' ] text_polys = data [ 'text_polys' ] ignore_tags = data [ 'ignore_tags' ] texts = data [ 'texts' ] all_care_polys = [ text_polys [ i ] for i , tag in enumerate ( ignore_tags ) if not tag ] # 计算crop区域 crop_x , crop_y , crop_w , crop_h = self . crop_area ( im , all_care_polys ) # crop 图片 保持比例填充 scale_w = self . size [ 0 ] / crop_w scale_h = self . size [ 1 ] / crop_h scale = min ( scale_w , scale_h ) h = int ( crop_h * scale ) w = int ( crop_w * scale ) if self . keep_ratio : if len ( im . shape ) == 3 : padimg = np . zeros ( ( self . size [ 1 ] , self . size [ 0 ] , im . shape [ 2 ] ) , im . dtype ) else : padimg = np . zeros ( ( self . size [ 1 ] , self . size [ 0 ] ) , im . dtype ) padimg [ : h , : w ] = cv2 . resize ( im [ crop_y : crop_y + crop_h , crop_x : crop_x + crop_w ] , ( w , h ) ) img = padimg else : img = cv2 . resize ( im [ crop_y : crop_y + crop_h , crop_x : crop_x + crop_w ] , tuple ( self . size ) ) # crop 文本框 text_polys_crop = [ ] ignore_tags_crop = [ ] texts_crop = [ ] for poly , text , tag in zip ( text_polys , texts , ignore_tags ) : poly = ( ( poly - ( crop_x , crop_y ) ) * scale ) . tolist ( ) if not self . is_poly_outside_rect ( poly , 0 , 0 , w , h ) : text_polys_crop . append ( poly ) ignore_tags_crop . append ( tag ) texts_crop . append ( text ) data [ 'img' ] = img data [ 'text_polys' ] = np . float32 ( text_polys_crop ) data [ 'ignore_tags' ] = ignore_tags_crop data [ 'texts' ] = texts_crop return data