AttributeError: module 'cv2.ximgproc' has no attribute 'niBlackThreshold'
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'
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
$ pip uninstall opencv-contrib-python opencv-python
And then,
$ pip install opencv-contrib-python
worked for me.