I want to read the time from the image below using Tesseract. My code is:
text = pytesseract.image_to_string('test.png')
print(text)
But for some reason, this program doesn't work, and the text is always a space. Does anyone know how to solve this problem?
Use the flag config="--psm 6"
and it should work. This specifies that you have a single uniform block of text. 7 also work which is for a single line of uniform text.
print(pytesseract.image_to_string('test.png', config="--psm 6"))
# prints "06-04-2021 11:27:17\n\x0c"
See this other post for another example https://stackoverflow.com/a/66179528/15271127
EDIT: Also see this website if you want more options https://muthu.co/all-tesseract-ocr-options/