Answer the question
In order to leave comments, you need to log in
How can digits be recognized with tesseract?
Good morning. I tried to write a program that would recognize text in a certain area (the code is presented below). But the program does not recognize the numbers in the picture. I have given an example of numbers below. There was an idea that this is such a text font, but most likely these numbers are made up of lines (well, just as numbers are drawn, so here). The essence of the problem is that tesseract does not recognize these characters, they are numbers. I hope for your help, thanks)
Code:
import pyautogui
import time
import numpy as np
import pyscreenshot as ImageGrab
import cv2
import os
import pytesseract
time.sleep(5)
filename = 'Image.png'
x = 1
last_time = time.time()
while(True):
screen = np.array(ImageGrab.grab(bbox=(671, 296, 1129, 423)))
print('loop took {} seconds'.format(time.time()-last_time))
last_time = time.time()
cv2.imshow('window', cv2.cvtColor(screen, cv2.COLOR_BGR2RGB))
cv2.imwrite(filename, screen)
x = x + 1
print(x)
if x == 2:
cv2.destroyAllWindows()
break
img = cv2.imread('Image.png')
pytesseract.pytesseract.tesseract_cmd = r'C:/Users/Admin/AppData/Local/Tesseract-OCR/tesseract.exe'
text = pytesseract.image_to_string(img)
print(text)
Answer the question
In order to leave comments, you need to log in
This task, as already written by Vladimir Kuts , can be solved using algorithms, but if you want it with tesseract, then:
1. You need to clear the image: remove the outer frame, make a greyscale image, etc., etc.
2. Choose a wrapper for tesseracta that will work best with your data.
Here is a little more detail - I wrote a long time ago, but during this time nothing fundamental has changed.
You have such numbers - that you can do without a tesseract
If you can, then please give a link to an article or any resource with this information, or tell us yourself if you have time and desire
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question