标签: python-tesseract

如何在python-tesseract中设置tessedit_write_images?

我试图设置tessedit_write_images但似乎无法做到,我无法在任何地方看到tessinput.tif

我正在做:

import tesseract

api = tesseract.TessBaseAPI()
api.Init(".","eng",tesseract.OEM_TESSERACT_ONLY)
api.SetPageSegMode(tesseract.PSM_AUTO_OSD)
api.SetVariable("tessedit_write_images", "T")
Run Code Online (Sandbox Code Playgroud)

但我尝试过"真实","1",以及更多变化,似乎根本不起作用.

有帮助吗?

tesseract python-tesseract

7
推荐指数
1
解决办法
1464
查看次数

如何在pytesseract中获得字符位置

我试图使用pytesseract库获取图像文件的字符位置.

import pytesseract
from PIL import Image
print pytesseract.image_to_string(Image.open('5.png'))
Run Code Online (Sandbox Code Playgroud)

是否有任何图书馆可以获得角色的每个位置

ocr image-processing python-2.7 python-tesseract pytesser

7
推荐指数
2
解决办法
4332
查看次数

WinError 5:访问被拒绝PyTesseract

我知道这个问题已经在这个网站上得到了回答,但是,我上网的解决方案似乎都没有.这是我试过的:

  • 授予我的python文件所有权限
  • 更改PATH变量以指向我的tesseract文件夹
  • 以管理员身份运行IDLE,然后从那里执行文件

这个错误让我非常困扰,因此无法继续前进.

这是我的代码,如果这将有所帮助:

import pytesseract
import sys
import argparse
try:
    import Image
except ImportError:
    from PIL import Image
from subprocess import check_output
pytesseract.pytesseract.tesseract_cmd = 'C:\Program Files\Tesseract-OCR'
c=pytesseract.image_to_string(Image.open('img.png'))
print(c)
Run Code Online (Sandbox Code Playgroud)

追溯:

Traceback (most recent call last):
  File "C:\Users\Hp\Desktop\bot.py", line 12, in <module>
    c=pytesseract.image_to_string(Image.open('captcha.png'))
  File "C:\Python\lib\site-packages\pytesseract\pytesseract.py", line 122, in image_to_string
config=config)
  File "C:\Python\lib\site-packages\pytesseract\pytesseract.py", line 46, in run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
  File "C:\Python\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
  File "C:\Python\lib\subprocess.py", line 992, in _execute_child
startupinfo)
PermissionError: [WinError 5] Accès …
Run Code Online (Sandbox Code Playgroud)

python windows ocr error-handling python-tesseract

7
推荐指数
3
解决办法
1455
查看次数

在pytesseract中使用image_to_osd方法时出现错误

这是我的代码:

import pytesseract
import cv2
from PIL import Image

pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files (x86)\Tesseract-OCR\tesseract.exe"


def main():
    original = cv2.imread('D_Testing.png', 0)
    # binary thresh it at value 100. It is now a black and white image
    ret, original = cv2.threshold(original, 100, 255, cv2.THRESH_BINARY)
    text = pytesseract.image_to_string(original, config='--psm 10')
    print(text)
    print(pytesseract.image_to_osd(Image.open('D_Testing.png')))


if __name__ == "__main__":
    main()
Run Code Online (Sandbox Code Playgroud)

对于第一个输出,我得到了我需要的字母D

D
Run Code Online (Sandbox Code Playgroud)

这是有意的,但是当它尝试执行第二个打印语句时,它会吐出它。

Traceback (most recent call last):
  File "C:/Users/Me/Documents/Python/OpenCV/OpenCV_WokringTest/PytesseractAttempt.py", line 18, in <module>
    main()
  File "C:/Users/Me/Documents/Python/OpenCV/OpenCV_WokringTest/PytesseractAttempt.py", line 14, in main
    print(pytesseract.image_to_osd(Image.open('D_Testing.png')))
  File "C:\Users\Me\Documents\Python\OpenCV\OpenCV_WokringTest\venv\lib\site-packages\pytesseract\pytesseract.py", line 402, …
Run Code Online (Sandbox Code Playgroud)

ocr tesseract python-3.x python-tesseract pytesser

7
推荐指数
3
解决办法
673
查看次数

tesseract 5.0 bazaar + 用户词配置不起作用

我试图强制 tesseract 在执行 OCR 时只使用我的单词列表。首先,我将集市文件复制到/usr/share/tesseract-ocr/5/tessdata/configs/. 这是我的集市文件:

load_system_dawg F
load_freq_dawg F
user_words_suffix user-words
Run Code Online (Sandbox Code Playgroud)

然后,我eng.user-words/usr/share/tesseract-ocr/5/tessdata. 这是我的用户词文件:

Items
VAT
included
CASH
Run Code Online (Sandbox Code Playgroud)

然后我通过命令对这个图像执行 ocr: tesseract -l eng --oem 2 test_small.jpg stdout bazaar

测试图像

这是我的结果:

2 Item(s) (VAT includsd) 36,000
casH 40,000
CHANGE 4. 000
Run Code Online (Sandbox Code Playgroud)

如您所见,includsd不在我的用户词文件中,它应该被“包含”。此外,即使没有bazaaz在命令中使用配置,我也得到了相同的结果。看起来 mybazaareng.user-wordsconfig 对 OCR 输出没有任何影响。那么如何使用bazaaruser-words配置,以获得想要的结果呢?

ocr tesseract python-tesseract

7
推荐指数
1
解决办法
1713
查看次数

如何提高python中扫描图像中文本的分辨率?

我使用 tesseract-OCR 从扫描图像中提取文本,对于少数图像,由于分辨率低而无法正确识别文本,并且产生的输出是一些不相关的字符。

应用技术:

  1. 将 dpi 增加到 300。

  2. opencv 中的图像预处理技术。

  3. 在 opencv 中使用 dnn_superres 放大图像

  4. 降噪技术。

  5. 参考 git repos,其中使用深度学习开发了超分辨率算法模型。

  6. 通过训练 tessdata 提高 tesseract-ocr 质量。

参考链接

  1. 提高扫描文档的 OCR 准确性
  2. 图像处理以提高tesseract OCR准确性

示例图像:

在此处输入图片说明

python中有没有什么简单的方法可以在不使用任何深度学习模型的情况下改进文本。

python image python-tesseract

7
推荐指数
1
解决办法
2862
查看次数

没有这样的文件或目录: 'tesseract': 'tesseract' 即使在 pytesseract.py 中指定了在哪里找到 tesseract

所以我一直在研究这个问题一段时间,而其他人也有类似的问题,但对我没有任何帮助:

我正在尝试将 pytesseract 用于一个项目,并将其安装在 User/Environments/testEnv/lib/python3.6/site-packages/pytesseract/

我在下面安装了tesseract usr/local/bin

我已经进入Users/User/Environments/testEnv/lib/python3.6/site-packages/pytesseract/pytesseract.py并改变tesseract_cmd = 'tesseract'tesseract_cmd = '/usr/local/bin/tesseract'如下建议:OSERROR:[错误2]没有这样的文件或目录使用pytesser

这没有用。我试图运行这个:

try:
    import Image
except ImportError:
    from PIL import Image
import pytesseract

img = Image.open('screenshot.png')
img.load()
i = pytesseract.image_to_string(img)
print (i)
Run Code Online (Sandbox Code Playgroud)

我明白了:

Traceback (most recent call last):
  File "/Users/User/Environments/testEnv/testTess.py", line 26, in <module>
    i = pytesseract.image_to_string(img)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pytesseract/pytesseract.py", line 122, in image_to_string
    config=config)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pytesseract/pytesseract.py", line 46, in run_tesseract
    proc = subprocess.Popen(command, stderr=subprocess.PIPE)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session) …
Run Code Online (Sandbox Code Playgroud)

python tesseract python-3.x python-tesseract

6
推荐指数
1
解决办法
5110
查看次数

如何在anaconda上为python安装tesseract

有谁知道如何在 Anaconda 上为 python 安装 tesseract?我有一个windows系统。anaconda 网站提供了 linux 系统的安装:

conda install -c auto pytesseract 
Run Code Online (Sandbox Code Playgroud)

Windows 系统是否需要进行任何更改?

python anaconda python-tesseract

6
推荐指数
3
解决办法
3万
查看次数

ModuleNotFoundError:没有名为“pytesseract”的模块

我在 Windows 10 上使用 Anaconda Navigator 1.7.0,我创建了一个名为“venv”的虚拟环境,并在其中安装了 Python 版本 3.5.2 以及 selenium、fuzzywuzzy 和其他模块。

除了 pytesseract 之外,一切都工作正常。

我的Python脚本:

import pytesseract

from PIL import Image

im =Image.open("C:\\Users\\stan\\Desktop\\sample.jpg")
text = pytesseract.image_to_string(im, lang ='eng')
print(text)
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

Traceback (most recent call last):
  File "C:\Users\stan\MyPythonScripts\tess11.py", line 1, in <module>
    import pytesseract
ModuleNotFoundError: No module named 'pytesseract'
Run Code Online (Sandbox Code Playgroud)

我使用 pip install 安装所有模块。

到目前为止我为解决这个问题所采取的步骤:

  1. 我使用虚拟环境pip install pytesseract(venv)在虚拟环境中安装了 pytesseract,
  2. 我查看了“site-packages”文件夹(..\Local\Continuum\anaconda3\envs\venv\Lib\site-packages),我确实看到“pytesseract”文件夹确实与“pytesseract-0.2.0”一起存在于其中.dist-info”。请注意,这也是我可以看到“selenium”和其他运行完美的模块的文件夹。
  3. 我安装 Pillow 只是为了确定一下。

  4. 我在网上研究了同样的错误,找到了解决方案,指出我应该pip install pytesseract检查 pytesseract 是否存在于我尝试运行的虚拟环境的“站点包”中,这两个步骤我都已经采取了。

  5. 我还安装了 tesseract-OCR 版本 3.05.01,默认情况下位于“C:\Program Files (x86)”

  6. 如果我尝试在“ModuleNotFoundError”下方再次运行 pip …

python python-3.x anaconda python-tesseract

6
推荐指数
0
解决办法
6844
查看次数

在 Tesseract 中保留空间

我有一个图像文件,其中包含一些由制表符(2 个空格)分隔的文本。但是当我从这个图像文件中提取文本时,我总是在两列之间得到一个空格。示例示例:

图片:

col-a    col-b    col-c
Run Code Online (Sandbox Code Playgroud)

期望的输出:

col-a    col-b    col-c
Run Code Online (Sandbox Code Playgroud)

但我得到以下信息:

col-a col-b col-c
Run Code Online (Sandbox Code Playgroud)

我正在使用 pytesseract.image_to_string(Python 模块)将图像转换为文本

python python-tesseract

6
推荐指数
1
解决办法
4391
查看次数