我想在python3中使用camelot从pdf中提取所有的表格。
import camelot
# PDF file to extract tables from
file = "./pdf_file/ooo.pdf"
tables = camelot.read_pdf(file)
# number of tables extracted
print("Total tables extracted:", tables.n)
# print the first table as Pandas DataFrame
print(tables[0].df)
# exp
我正在使用pytesseract,枕头,cv2来光学字符识别图像和获取图像中存在的文本。由于我的输入是扫描的PDF文档,因此我首先将其转换为图像(JPEG)格式,然后尝试提取文本。我只走了一半。输入是一个表格,并且不显示标题,因为标题具有黑色背景。我也尝试过获取getstructuringelement,但是想不出一种方法,我这样做了--
import cv2
import os
import numpy as np
import pytesseract
#import pillow
#Since scanned PDF can't be handled by pdf2ima
从我在网上收集到的内容来看,当尝试从python中的多个图像中提取文本时,使用tesserocr库应该比使用pytesseract更快,因为它不必每次都启动tesseract框架,它只是进行预测。但是,我实现了两个功能,如下所示:
api = tesserocr.PyTessBaseAPI()
# tessserocr function
def tessserocr_extract(p):
api.SetImageFile(p)
text = api.GetUTF8Text()
return text
# pytesseract function
def pytess