all repos — videocr @ 8f8f2d6d79b316bf995910329c2dfcfcf1269d59

Extract hardcoded subtitles from videos using machine learning

print muted exception from multiprocessing pool
Yi Ge me@yige.ch
Sun, 15 Dec 2019 22:29:13 +0800
commit

8f8f2d6d79b316bf995910329c2dfcfcf1269d59

parent

7b607e5ca7b7d058e9f4cc108b6c75b9ef7e1ba0

1 files changed, 6 insertions(+), 1 deletions(-)

jump to
M videocr/video.pyvideocr/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 @@ if not self.use_fullframe:

# 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)