我想从图像中提取表格。这个Python模块https://pypi.org/project/ExtractTable/及其网站https://www.extracttable.com/pro.html做得很好,但是他们的免费试用有限。我确实尝试了很多事情,但结果很不令人满意。该网站/Python 模块如何生成 100% 准确的表格。该解决方案应该适用于此驱动器链接上提供的这 3 个图像https://drive.google.com/drive/folders/1v3UDuR7dUFVMR1im7VHTXKqkxTIV9px9?usp=sharing
这是我尝试过的,效果很差。帮我提取类似该模块的表格。
import cv2 as cv
import numpy as np
import pytesseract
from pytesseract import Output
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (120,16)
ebl='data/manu.png'
ROI_number=0
image = cv.imread(ebl)
original=image
gray = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
custom_config = r'--oem 3 --psm 6'
details = pytesseract.image_to_data(gray, output_type=Output.DICT, config=custom_config, lang='eng')
total_boxes = len(details['text'])
for sequence_number in range(total_boxes):
if int(details['conf'][sequence_number]) >30:
(x, y, w, h) = (details['left'][sequence_number], details['top'][sequence_number], details['width'][sequence_number], details['height'][sequence_number])
threshold_img = cv.rectangle(original, (x, y), (x + w, y + h), (0, 255, 0), 2)
plotting = plt.imshow(threshold_img)
plt.show()
这是一个活跃的研究领域,因此,不会有一个完美的解决方案。如果您正在寻找更前沿的选项,Papers with Code 列出了几篇表格识别论文的结果,其中一些有您可以使用的免费模型,例如 TableMaster(在 Github 上实现了PaddleOCR) .
祝你好运!
你可以试试这个库。它并不完美,但可能适合您的用例。