Skip to main content
 首页 » 编程设计

Python Tesseract : int() argument must be a string, 类似字节的对象或数字,而不是 'tuple`

2024年12月31日9cyq1162

我是机器学习的初学者,我想尝试文本提取代码。这是我的代码:

import pytesseract from PIL import Image  
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files (x86)\Tesseract OCR.exe"  
img = Image.open('image.png')  
img.load() 
imgString = pytesseract.image_to_string(img) 

但是,这会导致此错误:

TypeError: int() argument must be a string, a bytes-like object or a number, not 'tuple`' 

我正在使用 Jupyter Notebook (python 3) 来运行这个程序。有什么我可以做的,或者有更简单的方法来从图像中提取文本吗?

请您参考如下方法:

Image.load() 方法

为图像分配存储空间并加载像素数据。一般情况下不需要调用该方法,Image类会在第一次访问时自动加载打开的图片。

img.load() 

到

#img.load()