簡體   English   中英

Tesseract ocr output 在檢測到的文本之間有單個字符

[英]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-thresholdblock-sizeC參數。 因此,請從閱讀自適應閾值開始

暫無
暫無

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

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