gpt4 book ai didi

python - 在 Python 上使用 Tesseract-OCR 的问题

转载 作者:行者123 更新时间:2023-12-01 09:22:07 24 4
gpt4 key购买 nike

我是编程新手,我正在尝试使用 Tesseract OCR 来读取图像的文本,但我无法使其工作!我在我的环境中安装了tesseract_OCR、pytesseract和pillow。有人有提示吗?

输入:

from PIL import Image 

import pytesseract

print( pytesseract.image_to_string( Image.open('phrase.jpg') ) )

输出:

 C:\Anaconda2\envs\ambiente36\python.exe 

C:/Users/Simone/Desktop/curso_programacao/Ler_imagens/ler_imagens

Traceback (most recent call last):

File "C:\Anaconda2\envs\ambiente36\lib\site-
packages\pytesseract\pytesseract.py", line 194, in run_and_get_output
run_tesseract(**kwargs)

File "C:\Anaconda2\envs\ambiente36\lib\site-
packages\pytesseract\pytesseract.py", line 165, in run_tesseract
proc = subprocess.Popen(command, **subprocess_args())

File "C:\Anaconda2\envs\ambiente36\lib\subprocess.py", line 709, in __init__
restore_signals, start_new_session)

File "C:\Anaconda2\envs\ambiente36\lib\subprocess.py", line 997, in
_execute_child
startupinfo)

FileNotFoundError: [WinError 2] O sistema não pode encontrar o arquivo
especificado

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/Simone/Desktop/curso_programacao/Ler_imagens/ler_imagens",
line 6, in <module>
phrase = pytesseract.image_to_string(Image.open('phrase.jpg'))

File "C:\Anaconda2\envs\ambiente36\lib\site-
packages\pytesseract\pytesseract.py", line 286, in image_to_string
return run_and_get_output(image, 'txt', lang, config, nice)

File "C:\Anaconda2\envs\ambiente36\lib\site-
packages\pytesseract\pytesseract.py", line 201, in run_and_get_output
raise TesseractNotFoundError()

pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed
or it's not in your path

最佳答案

在您的环境中配置 tessaract 时应遵循的步骤这是您应该遵循的步骤

首先安装python和pip here是步骤然后安装pillow,pytesseract为here

from PIL import Image
from pytesser.pytesser import *

image_file = "FULL/PATH/TO/YOUR/IMAGE/image.png"
im = Image.open(image_file)
text = image_to_string(im)
text = image_file_to_string(image_file)
text = image_file_to_string(image_file, graceful_errors=True)
print "=====output=======\n"
print text

链接 download皮特萨拉特你可以找到一个完整的例子 here

关于python - 在 Python 上使用 Tesseract-OCR 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50733572/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com