[英]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.