arush1836
arush1836

Reputation: 1547

Tesseract OCR produces empty results

I need to extract digits from images (see sample images). I tried pytesseract but it is not working, it produces empty results. Below is the code I am using

Code

import pytesseract
import cv2

img = cv2.imread('image_path')
digits = pytesseract.image_to_string(img)
print(digits)

Sample Images

enter image description here

enter image description here

I have a large pool of images, as shown above. Tesseract is not working on any of them.

Upvotes: 3

Views: 1356

Answers (1)

ExplodingGayFish
ExplodingGayFish

Reputation: 2897

Try adding config --psm 7 (meaning Treat the image as a single text line.)

import pytesseract
import cv2
img = cv2.imread('image_path')
digits = pytesseract.image_to_string(img,config='--psm 7')
print(digits)
#'971101004900 1545'

Upvotes: 3

Related Questions