簡體   English   中英

如何為 Pytesseract 處理此圖像?

[英]How to process this image for Pytesseract?

我想自動解決這樣的驗證碼。 我一直在嘗試處理圖像以使 Pytesseract 能夠讀取它,但沒有成功。

你能幫助我嗎?

圖片

我試試這個:

import cv2
from pytesseract import image_to_string
import pytesseract




img = cv2.imread("screenshot.png")
img = cv2.resize(img, (0, 0), fx=16, fy=16)
gry = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
(h, w) = gry.shape[:2]
gry = cv2.resize(gry, (w*2, h*2))
cls = cv2.morphologyEx(gry, cv2.MORPH_CLOSE, None)
#thr = cv2.threshold(cls, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1]
thr = cv2.threshold(gry, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1]
txt = image_to_string(,lang='eng', config='--psm 11')
cv2.imwrite('prv.png', thr)
print(txt)

AI/ML 解決驗證碼真的很難。 它們的核心是阻止 OCR。

考慮閱讀這個: https : //www.cloudflare.com/learning/bots/how-captchas-work/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM