python - Tesseract OCR 产生空结果

标签 python ocr tesseract python-tesseract

我需要从图像中提取数字(参见示例图像)。我试过 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 不适用于它们中的任何一个。

最佳答案

尝试添加配置--psm 7(意思是将图像视为单个文本行。)

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

关于python - Tesseract OCR 产生空结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59083559/

相关文章:

android - 操作位图以获得最佳 ocr 检测

python - 使用 create image share API with/ugcPosts 端点创建的帖子在我的时间轴上的 linkedin 上不可见

python - 用于使用 Datashader/Holoviews/Bokeh 循环子图

ocr - Tesseract 4 与 OCR 引擎模式一起使用时无法加载任何语言 - "Legacy + LSTM engines"(--oem 2)

windows - 如何从图像生成 tiff/box 文件以在 Windows 中训练 Tesseract

javascript - Tesseract.js 与 React : Tainted canvases may not be exported

android - 使用 Tesseract 的 OCR Android 应用程序

python - Pandas 创建列列表,其中行值包含 ' & "分隔符

python - 从 xml 文档中提取全部信息

java - 如何关闭tess4j中的字典?