H
H
Hcuy2020-06-07 18:10:19
Python
Hcuy, 2020-06-07 18:10:19

Recognizing digital digits in tesseract?

I need to recognize this picture
5edd00a59bb17400614431.jpeg
. To do this, I need to process it.
Here is the tesseract processing and recognition code. (sorry for stupid comments, I wrote them quickly specifically for the question)

import pytesseract as tess
tess.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"
import cv2
import matplotlib.pyplot as plt
import numpy as np


image = cv2.imread('image/1.2.jpeg')

foto = cv2.GaussianBlur(image,(11,11), 0) # размытие

kernel = np.ones((1,1), np.uint8)  #делает объекты на фото тоньше
foto = cv2.dilate(foto,kernel,iterations = 9)

foto = cv2.cvtColor(foto, cv2.COLOR_BGR2GRAY) #изменение цвета

(thresh, foto) = cv2.threshold(foto,95,155,cv2.THRESH_BINARY) # простой порог

foto = cv2.cvtColor(foto, cv2.COLOR_BGR2RGB) # изменение в серый цвет

result = tess.image_to_string(foto) #результат tess



cv2.imwrite('image/3.4.jpeg',foto)

plt.imshow(foto)
plt.show()

print (result)


Here is a photo of the output.
5edd01c5638bd800461995.png
And it seems to be normal. But tesseract doesn't read photos. When I start playing with values ​​in a function Most often it doesn't read anything, sometimes it reads something, but it's not at all correct. Perhaps I missed something in the processing of the photo, or in recognizing it. Thanks cv2.threshold(foto,95,155,cv2.THRESH_BINARY)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Ernest Faizullin, 2020-06-07
@Hcuy

Let's not make a bike. The task is old.
https://github.com/topics/number-recognition

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question