[英]how to classify if images contain text or not?
我有很多從搜索引擎中提取的圖像,我正在使用 OCR 從這些圖像中執行下降文本提取,但是有些圖像不包含文本。
因此,我想確定圖像是否僅包含 python 中的文本,如果沒有,我就不必對其執行 OCR。 理想情況下,這種方法具有很高的召回率。
使用 pytteseract。 像這樣的東西:
from PIL import Image
import pytesseract
def contains_text(image_path):
text = pytesseract.image_to_string(Image.open(image_path))
if text == "":
return False # No text detected
else:
return text
我不知道有一種方法可以在不嘗試執行 OCR 的情況下檢測到沒有文本(如上所示)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.