【发布时间】:2019-05-23 05:40:04
【问题描述】:
我正在尝试使用 Pytesseract 进行一些非常基本的字符识别。当我在 Linux 中运行以下代码时,输出是有意义的:
import matplotlib.pyplot as plt
import pandas as pd
import sys
import pytesseract
# need to add tesseract install location to path in windows.
if sys.platform == 'win32':
tesseract_path = r"C:\Program Files\Tesseract-OCR\tesseract.exe"
pytesseract.pytesseract.tesseract_cmd = tesseract_path
img = pd.read_csv('https://www.dropbox.com/s/fcs5bcmy73j75o0/two.csv?dl=1').values
fig,ax=plt.subplots()
ax.imshow(img.astype(float),cmap='gray')
print('identified as {}'.format(pytesseract.image_to_string(img.astype(float))))
但在 Windows 中对 pytesseract.image_to_string 的相同调用返回一个空字符串:
代码在 Python 3 环境中的两台机器上执行。
在我的 Windows 机器上安装 Tesseract 时,我可能遗漏了一个明显的步骤来解释这种行为吗?
Windows 中的 Tesseract 是使用以下安装程序安装的: https://github.com/UB-Mannheim/tesseract/wiki
在 Linux 中,我简单地使用了:
yum install tesseract
【问题讨论】:
-
我的猜测是文件夹结构存在差异。虽然在这里抓住稻草
标签: python python-3.x ocr tesseract python-tesseract