I'm trying to extract all score information from the scoreboard from a frame from a video using Tesseract OCR, but I'm having difficulties. I am either getting incorrect data, or not detecting the text I want.
I've tried doing it with grayscale conversion, inverting colors, resizing the image, and thresholding, but none of these methods seem to work. Additionally, I've tested different PSM without success.
Here's the image I am working with.
I've noticed that some online tools claim to use Tesseract OCR successfully for similar tasks and provide easily scrapeable score information. I'm wondering if there's something I'm missing or if there's a specific preprocessing step or Tesseract configuration that would improve the accuracy of the extraction.
Any assistance would be greatly appreciated!
My Output:
16:11
25
A
7
TIMEOUTS:
4
FOULS:
1
_
4
Website Output:
MICHIGAN ST
7
16:11 25
1ST HALF
4
2 PURDUE
17-11, 9-8 TIMEOUTS: 4 FOULS: 1
TIMEOUTS: 4
P
25-3, 14-3
My Code
capture = cv2.VideoCapture(file_path)while capture.isOpened(): ret, frame = capture.read() if not ret: break height, width = frame.shape[:2] crop_img = frame[int(height - (height / 5)):height, 0:width] crop_img = cv2.resize(crop_img, None, fx=2, fy=2, interpolation=cv2.INTER_CUBIC) gray = cv2.cvtColor(crop_img, cv2.COLOR_BGR2GRAY) inverted = cv2.bitwise_not(gray) bw = cv2.threshold(inverted, 0, 255, cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU)[1] blurred = cv2.GaussianBlur(crop_img, (5, 5), 0) data = pytesseract.image_to_data(crop_img, output_type=Output.DICT, lang='eng', config='--psm 6')