gpt4 book ai didi

python - pytesseract 输出未定义

转载 作者:行者123 更新时间:2023-11-28 22:21:23 26 4
gpt4 key购买 nike

尝试在 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/

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