img2table icon indicating copy to clipboard operation
img2table copied to clipboard

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

Open amir-bo opened this issue 1 year ago • 2 comments

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'

amir-bo avatar Jul 25 '24 16:07 amir-bo

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

CharlesMingus19 avatar Aug 12 '24 15:08 CharlesMingus19

$ pip uninstall opencv-contrib-python opencv-python

And then,

$ pip install opencv-contrib-python

worked for me.

YildirimCat avatar Dec 06 '24 08:12 YildirimCat