Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenCV error in cvtColor #148

Closed
alanbernstein opened this issue Oct 15, 2018 · 2 comments
Closed

OpenCV error in cvtColor #148

alanbernstein opened this issue Oct 15, 2018 · 2 comments

Comments

@alanbernstein
Copy link

Camelot failed with some OpenCV error on a personal document of mine. I tried again with this file https://arxiv.org/pdf/1706.05137.pdf, and saw the same error. This is just after having resolved ModuleNotFoundError: No module named 'cv2' with pip install opencv-python. I've used OpenCV on this machine without trouble before, but I'm not too familiar with the installation process/dependencies for OpenCV. Apologies if this is just a goofy problem with my setup.

Running this:

import camelot
tables = camelot.read_pdf("whatever.pdf")
tables[0]
tables[0].parsing_report
tables[0].df

I get this traceback:

Traceback (most recent call last):
  File "test.py", line 6, in <module>
    tables = camelot.read_pdf(fname)
  File "/usr/local/lib/python3.7/site-packages/camelot/io.py", line 91, in read_pdf
    tables = p.parse(flavor=flavor, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/camelot/handlers.py", line 146, in parse
    t = parser.extract_tables(p)
  File "/usr/local/lib/python3.7/site-packages/camelot/parsers/lattice.py", line 339, in extract_tables
    self._generate_table_bbox()
  File "/usr/local/lib/python3.7/site-packages/camelot/parsers/lattice.py", line 212, in _generate_table_bbox
    blocksize=self.threshold_blocksize, c=self.threshold_constant)
  File "/usr/local/lib/python3.7/site-packages/camelot/image_processing.py", line 38, in adaptive_threshold
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.error: OpenCV(3.4.3) /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/color.cpp:181: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

Note /Users/travis/ does not exist on my machine.

>>> import platform; print(platform.platform())
Darwin-16.7.0-x86_64-i386-64bit
>>> import sys; print('Python', sys.version)
Python 3.7.0 (default, Jul 23 2018, 20:24:19)
[Clang 9.0.0 (clang-900.0.39.2)]
>>> import numpy; print('NumPy', numpy.__version__)
NumPy 1.15.2
>>> import cv2; print('OpenCV', cv2.__version__)
OpenCV 3.4.3
>>> import camelot; print('Camelot', camelot.__version__)
Camelot 0.2.3
@vinayak-mehta
Copy link
Contributor

vinayak-mehta commented Oct 15, 2018

This is just after having resolved ModuleNotFoundError: No module named 'cv2' with pip install opencv-python.

@alanbernstein To install Camelot, you need to do pip install camelot-py[all] as given in the README.

A traceback with /Users/travis is weird, could be that opencv-python is built on Travis-CI before being uploaded to PyPI and you installed a broken build. Let me look into this.

@vinayak-mehta
Copy link
Contributor

@alanbernstein I was not able to reproduce this. Can you check if you face the same error with the most recent release? If yes, please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants