[英]Tesseract ocr output with single characters in between the detected text
我正在嘗試使用 Tesseract 從下圖中提取,
text = pytesseract.image_to_string(image, config='-c preserve_interword_spaces=1 --psm 1 --oem 1')
這是 tesseract 4 ocr 的結果,
print(text)
Wrote Datastream application
e Used Kafka to get the accounts
如果您看到圖像中的項目符號點被轉換為e
,我發現文檔中的幾個這樣的點被轉換為 ascii 中的單個字符
如果有人熟悉此類問題並有解決方案,請告訴我。
我有一個建議,也許最好刪除項目符號。
刪除要點的一種解決方案是應用adaptive-threshold
如果我們對當前圖像應用adaptive-threshold
:
現在,如果我們閱讀它:
Wrote Datastream application | Used Kafka to get the accounts
代碼:
import cv2
import pytesseract
img = cv2.imread("4XMue.png")
gry = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
thr = cv2.adaptiveThreshold(gry, 255, cv2.ADAPTIVE_THRESH_MEAN_C,
cv2.THRESH_BINARY, 11, 131)
txt = pytesseract.image_to_string(thr)
print(txt)
請讓我告訴您,我的示例代碼可能不適用於所有圖像。 由於圖像可能具有不同的偽影或需要額外的處理。 您可能需要更改adaptive-threshold
的block-size
和C
參數。 因此,請從閱讀自適應閾值開始
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.