Tesseract OCR产生空结果

问题描述 投票:0回答:1

我需要从图像中提取数字(请参阅示例图像)。我尝试了pytesseract,但是它不起作用,它会产生空结果。下面是我正在使用的代码

代码

import pytesseract
import cv2

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

样本图像

enter image description here

enter image description here

如上所述,我的图片池很大。 Tesseract对其中任何一个都不起作用。

python ocr tesseract python-tesseract
1个回答
0
投票

尝试添加配置--psm 7(表示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'
© www.soinside.com 2019 - 2024. All rights reserved.