Compare commits

...

3 Commits

View File

@ -4,6 +4,7 @@ import sys
import multiprocessing
import pytesseract
import cv2
import numpy as np
from . import constants
from . import utils
@ -69,7 +70,7 @@ class Video:
color_mask = cv2.inRange(hsv, (0, 0, 190), (179, 20, 255))
# apply mask, inverse image so it's black text on white background, add borders to top and bottom
img = cv2.copyMakeBorder(cv2.bitwise_not(cv2.bitwise_and(img, img, mask=color_mask)), 10, 10, 0, 0, cv2.BORDER_CONSTANT, None, (255,255,255)
img = cv2.copyMakeBorder(cv2.bitwise_not(cv2.bitwise_and(img, img, mask=color_mask)), 10, 10, 0, 0, cv2.BORDER_CONSTANT, None, (255,255,255))
config = '--tessdata-dir "{}" --psm 7 -c preserve_interword_spaces=1'.format(constants.TESSDATA_DIR)
try:
return pytesseract.image_to_data(img, lang=self.lang, config=config)