[英]Pytesseract: Cannot read digits on a relatively good quality image
试试这个代码
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.