Python PyteSeract图像到字符串函数一点也不精确

Python PyteSeract图像到字符串函数一点也不精确,python,ocr,tesseract,python-tesseract,Python,Ocr,Tesseract,Python Tesseract,我的代码 对于索引,枚举中的img(数据):#数据是base64解码字符串的列表 b64=base64.b64解码(字节(img[22:],encoding='utf-8')) 原始=字节(b64) im=Image.open(raw.convert('LA')) 像素=im.load() 宽度、高度=im尺寸 对于范围内的x(宽度): 对于范围内的y(高度): 如果像素[x,y][0]>100:pixels[x,y]=(255,255) 其他:像素[x,y]=(0255) 打印(pytesse

我的代码

对于索引,枚举中的img(数据):#数据是base64解码字符串的列表
b64=base64.b64解码(字节(img[22:],encoding='utf-8'))
原始=字节(b64)
im=Image.open(raw.convert('LA'))
像素=im.load()
宽度、高度=im尺寸
对于范围内的x(宽度):
对于范围内的y(高度):
如果像素[x,y][0]>100:pixels[x,y]=(255,255)
其他:像素[x,y]=(0255)
打印(pytesseract.image_to_字符串(im,config='tessedit_char_whitelist=1234567890plus?'))
我的形象:

输出:
Te Ys


我可以做些什么来改善这一点,我尝试在配置中使用从0到13的每一个psm和-c标志。这段代码对我来说很好,但没有检测到空格

    img = ~cv2.imread("18.png",0)
    rows,cols = img.shape[:2]
    # M = np.float32([[1,0,25],[0,1,15]])
    # img = cv2.warpAffine(img,M,(cols*2,rows*2),borderValue=(255,255,255))
    custom_oem_psm_config = r'--oem 3 --psm 3 -c tessedit_char_whitelist="1234567890plus?"'# -c preserve_interword_spaces=1'
    print(pytesseract.image_to_string(img,config=custom_oem_psm_config))
输出:

18plus16?

仍然需要帮助为图像添加一些填充。您尝试过简单的阈值设置吗?