Browse Source

Isolate subtitles as black over white background (kudos to u/Yun on hexbear.net)

pull/1/head
Pradana AUMARS 12 months ago
parent
commit
5534ae317f
  1. 1
      videocr/video.py

1
videocr/video.py

@ -56,6 +56,7 @@ class Video:
if not self.use_fullframe:
# only use bottom half of the frame by default
img = img[self.height // 2:, :]
img = cv2.bitwise_not(cv2.bitwise_and(img, img, mask=cv2.inRange(img, (190, 190, 190), (255, 255, 255))))
config = '--tessdata-dir "{}"'.format(constants.TESSDATA_DIR)
try:
return pytesseract.image_to_data(img, lang=self.lang, config=config)

Loading…
Cancel
Save