0

My goal is to have a working script for identifying a table on an image. I stumbled upon this posts answer: https://stackoverflow.com/a/51756462/10434683 He is exactly doing what I need. However if I run this code I get an error that looks like this:

enter image description here

It seems like the error is caused by the boundingRect() function. Ive looked up the docs, however didnt find anything useful.

The following is the function where boundingRect() is used...

def find_text_boxes(pre, min_text_height_limit=6, max_text_height_limit=40):
    # Looking for the text spots contours
    contours = cv2.findContours(pre, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
    contours = contours[0] if imutils.is_cv2() else contours[1]

    # Getting the texts bounding boxes based on the text size assumptions
    boxes = []
    for contour in contours:
        box = cv2.boundingRect(contour) #error
        h = box[3]

        if min_text_height_limit < h < max_text_height_limit:
            boxes.append(box)

    return boxes
Piglet
  • 27,501
  • 3
  • 20
  • 43
Dome271
  • 81
  • 2
  • 11
  • According to the error, verify that the contour which raise the error is not empty. – Lior Cohen Mar 22 '19 at 18:25
  • Any ideas how to do that @LiorCohen – Dome271 Mar 23 '19 at 09:46
  • Use debug breakpoint – Lior Cohen Mar 23 '19 at 10:27
  • Please do not post any errors as images. Write it out as code instead. – T A Mar 25 '19 at 08:51
  • Which version of OpenCV do you use in you program? OpenCV 3 version of `findContours` returns a tuple of `(img, contours, hierarchy)` and OpenCV 4 - `(contours, hierarchy)`. Check my answer here https://stackoverflow.com/questions/50829874/how-to-find-table-like-structure-in-image/51756462 for reference. – Dmytro Aug 26 '19 at 14:00

0 Answers0