Python 识别图片形式pdf的尝试(未解决)

作者 : admin 本文共369个字,预计阅读时间需要1分钟 发布时间: 2024-06-9 共2人阅读

想识别出pdf页面右下角某处的编号。pdf是图片形式页面。查了下方法,有源码是先将页面提取成jpg,再用pytesseract提取图片文件中的内容。

直接用图片来识别。纯数字的图片,如条形码,可识别。带中文的不可以,很乱。

Python 识别图片形式pdf的尝试(未解决)插图

识别为:

Python 识别图片形式pdf的尝试(未解决)插图(1)

如何形成wps图片中的文字识别效果呢?

Python 识别图片形式pdf的尝试(未解决)插图(2)

import pytesseract
from PIL import Image

def extract_text_from_image(image_path):
    image = Image.open(image_path)
    text = pytesseract.image_to_string(image)
    return text

image_path = r"D:.png"
text = extract_text_from_image(image_path)
print(f"图片内容:
{text}
")

 

本站无任何商业行为
个人在线分享 » Python 识别图片形式pdf的尝试(未解决)
E-->