如何提取图像中的表格

7 python ocr opencv scipy python-imaging-library

我想从图像中提取表格。这个 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()
Run Code Online (Sandbox Code Playgroud)