def __call__(self, image, return_score=False):
    output = self.scanner.scan(image)
    if self.find_best_rotation:
        _ = self.det_model(output, crop_region=True, return_result=False, output_path=CACHE_DIR)
        orientation_scores = np.array([0.0, 0.0, 0.0, 0.0])
        num_crops = len(os.listdir(self.crop_path))
        for i in range(num_crops):
            single_crop_path = os.path.join(self.crop_path, f'{i}.jpg')
            if (not os.path.isfile(single_crop_path)):
                continue
            img = cv2.imread(single_crop_path)
            img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
            orientation_scores += ocr.find_rotation_score(img, self.ocr_model)
        best_orient = np.argmax(orientation_scores)
        print(f'Rotate image by {(best_orient * 90)} degrees')
        output = ocr.rotate_img(output, best_orient)
    if return_score:
        return (output, orientation_scores)
    else:
        return output
def __call__(self, image, return_score=False):
    output = self.scanner.scan(image)
    if self.find_best_rotation:
        _ = self.det_model(output, crop_region=True, return_result=False, output_path=CACHE_DIR)
        orientation_scores = np.array([0.0, 0.0, 0.0, 0.0])
        num_crops = len(os.listdir(self.crop_path))
        for i in range(num_crops):
            single_crop_path = os.path.join(self.crop_path, f'{i}.jpg')
            if (not os.path.isfile(single_crop_path)):
                continue
            img = cv2.imread(single_crop_path)
            img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
            orientation_scores += ocr.find_rotation_score(img, self.ocr_model)
        best_orient = np.argmax(orientation_scores)
        print(f'Rotate image by {(best_orient * 90)} degrees')
        output = ocr.rotate_img(output, best_orient)
    if return_score:
        return (output, orientation_scores)
    else:
        return output