from PIL import Image
import pytesseract, time, PADBS
pytesseract.pytesseract.tesseract_cmd = r"C:/tesseract/Tesseract-OCR/tesseract.exe"
image = Image.open('3.png')
print(pytesseract.image_to_string(image))Image with '3' Image with '10'
当尝试读取“3.png”时,它结束时没有输出。但是当尝试读取'10.png‘时,它成功地读取了它。我尝试过在不同的配置上运行它;--oem3 -psm 13。我尝试过--oem1到3。但都不起作用。它无法识别此数字的可能原因是什么?我可以在代码中进行哪些更改才能使其正常工作?
发布于 2021-05-21 04:14:21
我想您错过了页面分割模式6
6假定有一个统一的文本块。Source
对于版本4.1.1,结果将为3。
代码:
import cv2
import pytesseract
# Load the image
img = cv2.imread("3.png")
# Convert to the gray-scale
gry = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# OCR
txt = pytesseract.image_to_string(gry, config="--psm 6")
# Print
print(pytesseract.get_tesseract_version())
print(txt)
# Display
cv2.imshow("", gry)
cv2.waitKey(0)4.1.1
3https://stackoverflow.com/questions/67588782
复制相似问题