From 8f8f2d6d79b316bf995910329c2dfcfcf1269d59 Mon Sep 17 00:00:00 2001 From: Yi Ge Date: Sun, 15 Dec 2019 22:29:13 +0800 Subject: [PATCH] print muted exception from multiprocessing pool --- videocr/video.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/videocr/video.py b/videocr/video.py index 754a17a..27ebdc3 100644 --- a/videocr/video.py +++ b/videocr/video.py @@ -1,4 +1,6 @@ from __future__ import annotations +from typing import List +import sys import multiprocessing import pytesseract import cv2 @@ -55,7 +57,10 @@ class Video: # only use bottom half of the frame by default img = img[self.height // 2:, :] config = '--tessdata-dir "{}"'.format(constants.TESSDATA_DIR) - return pytesseract.image_to_data(img, lang=self.lang, config=config) + try: + return pytesseract.image_to_data(img, lang=self.lang, config=config) + except Exception as e: + sys.exit('{}: {}'.format(e.__class__.__name__, e)) def get_subtitles(self, sim_threshold: int) -> str: self._generate_subtitles(sim_threshold)