jujumumu
jujumumu

Reputation: 390

Tesseract unable to read simple number

I have this imagethis image and I need tesseract to read the value.

import cv2
import pytesseract

im = cv2.imread("num.png")
print(pytesseract.image_to_string(im))

It does not print anything. Am I doing something wrong since it is pretty clear that it is a 7.

Even after scaling the image up by 5x with intercubic it still would not work. This is the image now enter image description here

Upvotes: 0

Views: 596

Answers (2)

R. Marolahy
R. Marolahy

Reputation: 1596

As described here:

By default Tesseract expects a page of text when it segments an image. If you’re just seeking to OCR a small region, try a different segmentation mode, using the --psm argument.

In this case, --psm from 6 to 10 should work fine. Example:

pytesseract.image_to_string(im, config='--psm 6')

Upvotes: 4

Jitesh
Jitesh

Reputation: 318

The code is correct. I think that image of 7 is not clear enough for pytesseract. You need to preprocess the image. This link might help.

Upvotes: 2

Related Questions