我正在尝试将配置参数传递给pytesseract的image_to_string函数。
我正在运行的代码如下。
filename = 'address1_203.png'
img = Image.open(cam_img+filename)
ocr_out = ocr.image_to_string(img, lang='por', config='-psm 7')
print(ocr_out)
错误消息是
TypeError: image_to_string() got an unexpected keyword argument 'config'
在stackoverflow中还有另一个类似的问题,但我认为它不能解决我遇到的问题。
我通过康达安装了pytesseract,conda install -c auto pytesseract
如果我删除config
参数,代码有效
PS:这是我发布的第一个问题,如果我做得正确,请给我反馈。 谢谢=(
这是我第一次使用tesseract,也许你应该尝试一下这种符号。
image_url = 'test2.png'
custom_config = r'-l por --psm 7'
print(pytesseract.image_to_string(image_url, config=custom_config))
重要的是要知道环境(Windows,linux等(应该安装tesseract,在这种情况下,我使用ubuntu并且我以这些方式安装了tesseract
。sudo apt install tesseract-ocr
sudo apt-get install tesseract-ocr-por -y
然后您可以检查安装的语言
tesseract --list-langs
https://github.com/NanoNets/ocr-with-tesseract/blob/master/tesseract-tutorial.ipynb
尝试使用 builder=pyocr.builders.TextBuilder(tesseract_layout=6(