我正在尝试让我的程序使用Tesseract来识别中文,它起作用了。我遇到的唯一问题是把结果打印成中文字符,结果是用拼音打印出来的(你怎么把中文单词打成英文)。
# Import libraries
from PIL import Image
import pytesseract
from unidecode import unidecode
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"
image_counter = 2
filelimit = image_counter - 1
outfile = "out_text.txt"
f = open(outfile, "a")
for i in range(1, filelimit + 1):
print("ran")
filename = "page_" + str(i) + ".png"
# Recognize the text as string in image using pytesserct
text = unidecode(((pytesseract.image_to_string(Image.open(filename), lang = "chi_sim"))))
print(text)这是我运行的图像

这就是我得到的
ran Qing Ming Shi Jie Yu Fen Fen , Lu Shang Xing Ren Yu Duan Que Xin Wen Jiu Jia He Chu You , Mu Yi Tong Zhi Qiang Hua Cun .
结果应该是图像中所示的汉字。
发布于 2019-09-10 16:21:11
不要紧,我意识到我的问题了。
text = unidecode(((pytesseract.image_to_string(Image.open(filename), lang = "chi_sim"))))应该是
text = pytesseract.image_to_string(Image.open(filename), lang = "chi_tra")https://stackoverflow.com/questions/57866592
复制相似问题