xavctn / img2table

img2table is a table identification and extraction Python Library for PDF and images, based on OpenCV image processing
MIT License
571 stars 76 forks source link

AttributeError: module 'cv2.ximgproc' has no attribute 'niBlackThreshold' #208

Open amir-bo opened 4 months ago

amir-bo commented 4 months ago

When running:

from img2table.document import Image

img_path = "/Users/amir.giveon/Downloads/g1_t2.jpg"

img = Image(src=img_path)

extracted_tables = img.extract_tables()

I get:

File "/Users/amir.giveon/GoogleDrive/pycharmProjects/venvs/k1analysis/lib/python3.11/site-packages/img2table/tables/init.py", line 39, in threshold_dark_areas t_sauvola = cv2.ximgproc.niBlackThreshold(img, 255, cv2.THRESH_BINARY_INV, thresh_kernel, 0.2, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'cv2.ximgproc' has no attribute 'niBlackThreshold'

CharlesMingus19 commented 3 months ago

You need to uninstall all opencv packages you have installed, as you can only have one.

Then install this opencv package: opencv-contrib-python-headless