brian-yang / table-parser-opencv Goto Github PK
View Code? Open in Web Editor NEWExtract tables from images or PDFs and convert them to Excel files
License: MIT License
Extract tables from images or PDFs and convert them to Excel files
License: MIT License
import utils
tables = [] # list of tables
for i in range(len(contours)):
# Verify that region of interest is a table
(rect, table_joints) = utils.verify_table(contours[i], intersections)
if rect == None or table_joints == None:
continue
# Create a new instance of a table
table = Table(rect[0], rect[1], rect[2], rect[3])
# Get an n-dimensional array of the coordinates of the table joints
joint_coords = []
for i in range(len(table_joints)):
joint_coords.append(table_joints[i][0][0])
joint_coords = np.asarray(joint_coords)
# Returns indices of coordinates in sorted order
# Sorts based on parameters (aka keys) starting from the last parameter, then second-to-last, etc
sorted_indices = np.lexsort((joint_coords[:, 0], joint_coords[:, 1]))
joint_coords = joint_coords[sorted_indices]
# Store joint coordinates in the table instance
table.set_joints(joint_coords)
tables.append(table)
Hi Brian ,
I am getting this issue while running the code
D:\data\POC\table-parser-opencv-master>python main.py D:\data\POC\test.pdf
Traceback (most recent call last):
File "main.py", line 161, in
fname = utils.run_textcleaner(fname, num_img)
File "D:\data\POC\table-parser-opencv-master\utils.py", line 69, in run_textcleaner
s.call(["./textcleaner", "-g", "-e", "none", "-f", str(10), "-o", str(5), filename, cleaned_file])
File "D:\Python37-32\lib\subprocess.py", line 323, in call
with Popen(*popenargs, **kwargs) as p:
File "D:\Python37-32\lib\subprocess.py", line 775, in init
restore_signals, start_new_session)
File "D:\Python37-32\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
OSError: [WinError 193] %1 is not a valid Win32 application
I tried to do OCR on a scanned PDF I have with tables but it didn't work. Is there a way I can send you the pdf?
Hello,
I had an inquiry from one of your table-parser-opencv users with a problem. To my surprise, when I looked into your git page, I see that your code uses my textcleaner, bash unix shell script that calls Imagemagick without my permission. Look carefully at my license at the top of the script.
Please contact me about this at fmw at alink dot net.
If you had previously contacted me, my apologies. However, there is inadequate reference to me an my work in your README file and to my licensing conditions.
Fred W
The input is being copied to target.jpg
, but by doing this, the file is being compressed unnecessarily, adding compression artifacting: https://github.com/brian-yang/table-parser-opencv/blob/master/main.py#L27
Should I open a PR to change it to target.png
?
Traceback (most recent call last):
File "D:\Python\Python37\lib\code.py", line 90, in runcode
exec(code, self.locals)
File "", line 1, in
File "D:\PyCharm Community Edition 2022.2.1\plugins\python-ce\helpers\pydev_pydev_bundle\pydev_umd.py", line 198, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "D:\PyCharm Community Edition 2022.2.1\plugins\python-ce\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "E:/table-parser-opencv-master/main.py", line 164, in
text = utils.run_tesseract(fname, num_img, psm, oem)
File "E:\table-parser-opencv-master\utils.py", line 79, in run_tesseract
image = Image.open(filename)
File "E:\table-parser-opencv-master\venv\lib\site-packages\PIL\Image.py", line 2904, in open
fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'bin/cleaned/cleaned0.jpg'
The issue is on MacOS mojave
Python 3.7.8
ImageMagick 7.0.10-28 Q16 x86_64 2020-08-16
Is it need to train the data set?
It is partially working for scanned images. It crops just a few boxes from the entire table. Please suggest changes.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.