繁体   English   中英

Pytesseract:无法读取质量相对较好的图像上的数字

[英]Pytesseract: Cannot read digits on a relatively good quality image

我有如下图像:

在此处输入图像描述

使用 tesseract 命令:

pytesseract.image_to_string(box_img_6, config="--lang= 'eng' --psm 6 --oem 3")

我得到 output: 'nu'

我认为 tesseract 应该在这张图片上表现更好,并且至少可以读取一些数字。

你能帮我提高 Tesseract 的性能吗?

谢谢你。

试试这个代码

import pytesseract
from PIL import Image
pytesseract.pytesseract.tesseract_cmd = (r"C:\Tesseract-OCR\tesseract.exe")
text = pytesseract.image_to_string(Image.open(r"a.jpg"), lang='eng',
                        config='--psm 10 --oem 3 -c tessedit_char_whitelist=0123456789')

print(text)

Output

**3008**

您应该阅读提高 output 的质量

但是对于输入图像,您不需要应用任何预处理或设置任何配置参数,结果:

txt = pytesseract.image_to_string(gray_image)

将会:

3008

在当前最新版本的 pytesseract ( 0.3.7 )

代码:


import cv2
import pytesseract

# Load the image
img = cv2.imread("wwckp.jpg")

# Convert to the gray-scale
gry = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# OCR
txt = pytesseract.image_to_string(gry)
print(txt)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM