Skip to content

Instantly share code, notes, and snippets.

View thxtex's full-sized avatar

Thomas Szücs thxtex

View GitHub Profile
@scottpanton
scottpanton / googleocr.py
Created December 27, 2020 03:44
Use Google Vision API to OCR subtitles from https://sourceforge.net/p/videosubfinder
import io,os,glob
from google.cloud import vision
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'creds.json'
path = '/some/place/'
srcdir = 'TXTImages'
frames = glob.glob(path + srcdir + '/*.jpeg')
client = vision.ImageAnnotatorClient()
@scottpanton
scottpanton / crop.py
Created December 27, 2020 03:39
Crop RGBImages from https://sourceforge.net/p/videosubfinder to only include subtitles identified in TXTImages for use with Google Vision API
import cv2,os,numpy,math,glob
path = '/some/place/'
frames = [os.path.basename(x) for x in glob.glob(path + 'TXTImages/*.jpeg')]
#add padding around sub
pad = 40
for frame in frames:
print(frame)
txtpath = path + 'TXTImages/' + frame