python - pytesseract 输出未定义

标签 python ubuntu tesseract python-tesseract pytesser

尝试在 python 上运行 tesseract,这是我的代码:

import cv2
import os
import numpy as np
import matplotlib.pyplot as plt
import pytesseract
import Image
# def main():
jpgCounter = 0
    for root, dirs, files in os.walk('/home/manel/Desktop/fotografias etiquetas'):
    for file in files:
        if file.endswith('.jpg'):
        jpgCounter += 1

for i in range(1, 2):

    name                = str(i) + ".jpg"
    nameBW              = str(i) + "_bw.jpg"
    img                 = cv2.imread(name,0) #zero -> abre em grayscale
    # img                 = cv2.equalizeHist(img)
    kernel = np.array([[0,-1,0], [-1,5,-1], [0,-1,0]])
    img = cv2.filter2D(img, -1, kernel)
    cv2.normalize(img,img,0,255,cv2.NORM_MINMAX)
    med                 = np.median(img)



    retval, threshold_manual    = cv2.threshold(img, med*0.6, 255, cv2.THRESH_BINARY)
    cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY,11,2)
    print(pytesseract.image_to_string(threshold_manual, lang='eng', config='-psm 11', nice=0, output_type=Output.STRING))

我收到的错误如下:

NameError: name 'Output' is not defined

知道我为什么会收到这个吗? 谢谢!

最佳答案

添加。

from pytesseract import Output

关于python - pytesseract 输出未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48357030/

相关文章:

python - Django:如何在我的模板中有效显示数据?

php - PHP 脚本中的 SED 命令(错误表达式 #1,char 34 : Invalid preceding regular expression)

python - pytesseract : Can't access Image with "Image.open" "Errno 2" error

ubuntu - 用pip安装后, "jupyter: command not found"

python - 创建conda环境: "Found conflicts!" when solving environment and "Finding shortest conflict path" running forever

Android OCR 应用程序 : Tesseract dictionary

java - Tess4j:tess4j java 中的内存访问错误

python - Pandas 数据框列的中位数

python - 对数据框的行进行排序并更改每隔一行的值时出现问题

Python Q 学习实现不起作用