Below are the code and error which I encountered.
Please help me to fix this error. Thanks in advance
The code works well for most images, but for a few images, I am getting the error shown below. The error occurs during table extraction step
from img2table.ocr import PaddleOCR
from img2table.document import Image
# Instantiation of OCR
ocr = PaddleOCR(lang="en")
doc=Image("imgpath")
# Table extraction
extracted_tables = doc.extract_tables(ocr=ocr,
implicit_rows=False,
implicit_columns=False,
borderless_tables=False,
min_confidence=50)
Traceback (most recent call last):
File "c:UsersgiriDesktoppythontableDetctionDataExtractiontest.py", line 47, in <module>
extract_table_data(r'C:UsersgiriDesktoppythontableDetctionDataExtractiondetectedTables')
File "c:UsersgiriDesktoppythontableDetctionDataExtractiontest.py", line 23, in extract_table_data
extracted_tables = doc.extract_tables(ocr=ocr,
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:UsersgiriDesktoppythontableDetctionDataExtractionmyenvLibsite-packagesimg2tabledocumentimage.py", line 48, in extract_tables
extracted_tables = super(Image, self).extract_tables(ocr=ocr,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:UsersgiriDesktoppythontableDetctionDataExtractionmyenvLibsite-packagesimg2tabledocumentbase__init__.py", line 127, in extract_tables
tables = {idx: TableImage(img=img,
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:UsersgiriDesktoppythontableDetctionDataExtractionmyenvLibsite-packagesimg2tabledocumentbase__init__.py", line 128, in <dictcomp>
min_confidence=min_confidence).extract_tables(implicit_rows=implicit_rows,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:UsersgiriDesktoppythontableDetctionDataExtractionmyenvLibsite-packagesimg2tabletablesimage.py", line 129, in extract_tables
self.extract_bordered_tables(implicit_rows=implicit_rows,
File "C:UsersgiriDesktoppythontableDetctionDataExtractionmyenvLibsite-packagesimg2tabletablesimage.py", line 66, in extract_bordered_tables
h_lines, v_lines = detect_lines(img=self.img,
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:UsersgiriDesktoppythontableDetctionDataExtractionmyenvLibsite-packagesimg2tabletablesprocessingbordered_tableslines.py", line 112, in detect_lines
h_lines = identify_straight_lines(thresh=binary_img,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:UsersgiriDesktoppythontableDetctionDataExtractionmyenvLibsite-packagesimg2tabletablesprocessingbordered_tableslines.py", line 23, in identify_straight_lines
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, kernel_dims)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cv2.error: OpenCV(4.10.0) d:aopencv-pythonopencv-pythonopencvmodulesimgprocsrcfilterengine.hpp:367: error: (-215:Assertion failed) anchor.inside(Rect(0, 0, ksize.width, ksize.height)) in function 'cv::normalizeAnchor'
9