gpt4 book ai didi

python 立方体 "AttributeError: setImage"

转载 作者:太空宇宙 更新时间:2023-11-04 10:30:33 25 4
gpt4 key购买 nike

我正在尝试让 tesseract 在 python 中运行:

...image is a numpy array (uint8)...

tessApi = tesseract.TessBaseAPI()
tessApi.Init(".","spa",tesseract.OEM_DEFAULT)
tessApi.SetVariable("tessedit_char_whitelist", "0123456789ACEIMNOPRSTU/imn")
tessApi.SetPageSegMode(tesseract.PSM_AUTO)
# SetImage(imagedata, width, height, bytes_per_pixel, bytes_per_line)
w = int(final.shape[1])
h = int(final.shape[0])
tessApi.setImage(image,w,h,1,w)
text = tessApi.GetUTF8Text()
print text

我得到一个错误:引发 AttributeError(名称)属性错误:setImage我不知道为什么。拜托,任何人都可以帮助我吗?

最佳答案

检查 https://code.google.com/p/python-tesseract/source/browse/python-tesseract-0.9/src/tesseract.py

class TessBaseAPI(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, TessBaseAPI, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, TessBaseAPI, name)
__repr__ = _swig_repr
def __init__(self):
this = _tesseract.new_TessBaseAPI()
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _tesseract.delete_TessBaseAPI
__del__ = lambda self : None;
__swig_getmethods__["Version"] = lambda x: _tesseract.TessBaseAPI_Version
if _newclass:Version = staticmethod(_tesseract.TessBaseAPI_Version)
__swig_getmethods__["getOpenCLDevice"] = lambda x: _tesseract.TessBaseAPI_getOpenCLDevice
if _newclass:getOpenCLDevice = staticmethod(_tesseract.TessBaseAPI_getOpenCLDevice)
__swig_getmethods__["CatchSignals"] = lambda x: _tesseract.TessBaseAPI_CatchSignals
if _newclass:CatchSignals = staticmethod(_tesseract.TessBaseAPI_CatchSignals)
def SetInputName(self, *args): return _tesseract.TessBaseAPI_SetInputName(self, *args)
def GetInputName(self): return _tesseract.TessBaseAPI_GetInputName(self)
...
def ClearAdaptiveClassifier(self): return _tesseract.TessBaseAPI_ClearAdaptiveClassifier(self)
def SetImage(self, *args): return _tesseract.TessBaseAPI_SetImage(self, *args)

您尝试调用的函数是

def SetImage(self, *args): return _tesseract.TessBaseAPI_SetImage(self, *args)

对 SetImage 使用大写 S,而不是小写

关于 python 立方体 "AttributeError: setImage",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27017793/

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