I am trying to use pytesseract to read images like this:
I thought that should be rather easy, but I can't get it to work so far. I tried different sorts of preprocessing but it doesn't work:
image = cv2.imread('number.png')
custom_config = r'-c tessedit_char_whitelist=0123456789 --psm 10'
text_i = pytesseract.image_to_string(img, config=custom_config)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
text_g = pytesseract.image_to_string(img, config=custom_config)
thresh = cv2.threshold(image, 50, 255, cv2.THRESH_BINARY)[1]
text_t = pytesseract.image_to_string(img, config=custom_config)
plt.axis('off')
plt.imshow(image)
plt.show()
print("Recognized number: ", text_i)
plt.axis('off')
plt.imshow(gray)
plt.show()
print("Recognized number: ", text_g)
plt.axis('off')
plt.imshow(thresh)
plt.show()
print("Recognized number: ", text_t)
In all cases, the returned string is empty. Does anyone have an idea, what to do?