Skip to main content
 首页 » 编程设计

python之从图像中提取文本。文字识别

2025年02月15日8pengyingh

我正在使用 Pytesseract,当我使用英语时它可以工作,但是当我切换到俄语时它可以工作。我有这样的问题:

"TypeError: 'str' does not support the buffer interface". I've tried other language it also doesn't work.

这是我的代码:

from PIL import Image 
from pytesseract import image_to_string 
k=image_to_string(Image.open("ff.jpg"), lang="rus") 
print(image_to_string(Image.open("picture.jpg"), lang="rus")) 

谁能帮我解决这个问题?

请您参考如下方法:

您需要为特定语言的 Tesseract 训练数据 您需要在系统中复制语言支持文件 作为引用,您可以访问该站点:- https://github.com/tesseract-ocr/langdata