在 Python 中从图像的无边框表格中提取文本

发布于 2025-01-14 10:40:52 字数 345 浏览 0 评论 0原文

我是 opencv 的新手,需要帮助从图像中存在的无边框表格中提取文本。需要从下图中提取文本。 输入图片

我想提取文本并将信息放入数据框中。

预期产出 预期输出

I am new to opencv and need help in extracting text from a borderless table present in an image. Need to extract text from the below image. Input Image

I want to extract text and put the information in a data frame.

Expected output
Expected Output

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橪书 2025-01-21 10:40:52

单独使用 openCV 提取无边框表格是一个挑战。但是,您可以使用 paddleocr 来检测和 OCR 表格。
下面是一个代码示例:

import cv2
import pandas as pd
from paddleocr import PPStructure

table_engine = PPStructure(recovery=True, return_ocr_result_in_table=True)


img_path = 'table_image.jpeg'
img = cv2.imread(img_path)
result = table_engine(img)

for line in result:
    line.pop('img')
    if line.get("type") == "table":
        html_table = line.get("res").get("html")
        html_data = pd.read_html(html_table)
        pd.DataFrame(html_data[0])

Extracting borderless tables using openCV alone is a bit of a challenge. However, you can use paddleocr to detect and OCR the table.
Below is a code sample:

import cv2
import pandas as pd
from paddleocr import PPStructure

table_engine = PPStructure(recovery=True, return_ocr_result_in_table=True)


img_path = 'table_image.jpeg'
img = cv2.imread(img_path)
result = table_engine(img)

for line in result:
    line.pop('img')
    if line.get("type") == "table":
        html_table = line.get("res").get("html")
        html_data = pd.read_html(html_table)
        pd.DataFrame(html_data[0])
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文