我使用 pytesseract 编写了一个代码,每当我运行它时,我都会收到此错误:
TesseractNotFoundError: tesseract is not installed or it's not in your path
我已经使用 HomeBrew 安装了 tesseract 并且也pip安装了它。
有没有办法用超正方体逐行读取图像并获取线的坐标?通常我可以读取 tesseract 返回字典中的每个单词,并且可以获得所有位置,但没有线坐标选项?我正在使用 psm 6 逐行读取,但即使我使用它,我也会收到单词的坐标
d = pytesseract.image_to_data(img, lang="eng", output_type=Output.DICT)
Run Code Online (Sandbox Code Playgroud) 当我使用 Pytesseract 识别该图像中的文本时,Pytesseract 返回7A51k但该图像中的文本是7,451k。
如何使用代码解决此问题而不是提供更清晰的源图像?
我的代码
import pytesseract as pytesseract
from PIL import Image
pytesseract.pytesseract.tesseract_cmd = 'D:\\App\\Tesseract-OCR\\tesseract'
img = Image.open("captured\\amount.png")
string = pytesseract.image_to_string(image=img, config="--psm 10")
print(string)
Run Code Online (Sandbox Code Playgroud) 错误 :pytesseract.pytesseract.TesseractError: (127, 'tesseract: error while loading shared libraries: libarchive.so.13: cannot open shared object file: No such
我的 apt 文件如下所示:
libgl1 libsm6 libxrender1 libfontconfig1 libarchive-dev libtesseract-dev tesseract-ocr tesseract-ocr-eng
我的需求文件已经pytesseract提到了。
我添加了一个构建包,设置了 TESSDATA_PREFIX 配置变量路径。
问题依然存在。
我一直在开发一个使用光学字符识别来读取财务报表的程序,我一生都无法弄清楚为什么我正在使用的开源模块仍然无法读取某些数字。
我创建了一个输出文件,在原始输入周围带有绿色框,其中正在检测文本。在这种情况下,带有“381”的行被选取,但下面的行(具有相同的精确格式)被忽略。
我在提取数据之前使用此代码对图像进行预处理,因为之前的丢失率高达 20%,现在接近 5%。
img = cv2.imread(filename)
img = cv2.resize(img, None, fx=1.2, fy=1.2, interpolation=cv2.INTER_CUBIC)
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
kernel = np.ones((1, 1), np.uint8)
img = cv2.dilate(img, kernel, iterations=1)
img = cv2.erode(img, kernel, iterations=1)
Run Code Online (Sandbox Code Playgroud)
在此预处理之后,我还运行了一种算法,从文档中删除超过一定大小的实线,但在这种情况下,“35”或“381”在原始文件中都没有下划线,所以我怀疑这是导致问题的原因。我还验证了 5 的顶部部分没有被线条检测算法删除。
我不是 OCR 或 CV 方面的专家,我的专长是更多数据和通用编程——我真的只需要让这个库完成它所宣传的工作,这样我就可以继续并完成程序。有谁知道可能导致此问题的原因是什么?
我有一个包含多列的数据框(我从pytesseract.image_to_data(img_pl,lang="eng", output_type='data.frame', config='--psm 11')[使用的 psm 11 或 12,相同的结果] 获取它并仅从中获取重要的列),让我们看看以下列:
# This is the data I get from the above command,
# I added it like that so you will be able to copy and test it
data = {'left': [154, 154, 200, 154, 201, 199],
'top': [0, 3, 3, 7, 8, 12],
'width': [576, 168, 162, 168, 155, 157],
'height': [89, 10, 10, 10, 10, 10],
'text': ['text1', 'text2', 'text3', 'text4', 'text5', 'text6']}
output_test_min_agg = pd.DataFrame(data)
# Output: …Run Code Online (Sandbox Code Playgroud) > import image
> import pytesseract as pya
>
> pya.tesseract_cmd = r'C:\Users\Euphz\Documents\Artworks\PSD\Speaking
of Dogs\201710'
> print(pya.image_to_string(image.open('doggieville.png')))
Run Code Online (Sandbox Code Playgroud)
回溯(最近一次调用):文件“C:\PythonProjects\pytesseract.py”,第 2 行,在 import pytesseract as pya 文件“C:\PythonProjects\pytesseract.py”,第 5 行,在 print(pya.image_to_string( image.open('doggieville.png'))) AttributeError: 模块 'pytesseract' 没有属性 'image_to_string'
为什么会发生???
我正在尝试使用tesseract-OCR从图像中打印文本。但我收到上述错误。我已使用pip install pytesseract在anaconda提示符中使用https://github.com/UB-Mannheim/tesseract/wiki和pytesseract 安装了tesseract OCR,但它不起作用。如果有人遇到过类似问题,请提供帮助。
(基本)C:\ Users \ 500066016> pip install pytesseract收集pytesseract下载https://files.pythonhosted.org/packages/13/56/befaafbabb36c03e4fdbb3fea854e0aea294039308a93daf6876bf7a8d6b/pytesseractz 0.2.4(?169)。 ?????????????????????????????????? | 174kB 288kB / s已满足要求:存放在c:\ users \ 500066016 \ appdata \ local \ continuum \ anaconda3 \ lib \ site-packages中(来自pytesseract)(5.1.0)组装收集包的轮子:pytesseract正在运行setup.py pytesseract的bdist_wheel ...完成存储在目录中:C:\ Users \ 500066016 \ AppData \ Local \ pip \ Cache \ wheels \ a8 \ 0c \ 00 \ 32e4957a46128bea34fda60b8b01a8755986415cbab3ed8e38成功构建pytesseract
下面是代码:
import pytesseract
import cv2
import numpy as np
def get_string(img_path):
img = cv2.imread(img_path)
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
kernel = …Run Code Online (Sandbox Code Playgroud) 我有一个如下图像:
我想从中提取文本,应该是ws35,我尝试使用pytesseract库使用该方法:
pytesseract.image_to_string(Image.open(path))
Run Code Online (Sandbox Code Playgroud)
但它什么也没有回报......我做错了什么?如何使用OCR取回文本?我需要在它上面应用一些过滤器吗?
我已经阅读了关于pytesseract的帖子,但是我无法通过一个简单的图像读取文本.它返回一个空字符串.
这是图像:
我尝试过缩放,灰度化,调整对比度,阈值,模糊,以及其他帖子中说的所有内容,但我的问题是我不知道OCR想要更好地工作.它需要模糊的文字吗?高对比度?
代码尝试:
import pytesseract
from PIL import Image
print pytesseract.image_to_string(Image.open(IMAGE FILE))
Run Code Online (Sandbox Code Playgroud)
正如您在我的代码中看到的那样,图像存储在我的计算机本地 Image.open()
python-tesseract ×10
python ×8
tesseract ×4
python-3.x ×3
ocr ×2
dataframe ×1
deployment ×1
heroku ×1
macos ×1
opencv ×1
pandas ×1