OpenCV boundingRect()函数引发意外错误

时间:2019-03-22 18:20:33

标签: python image-processing

我的目标是要有一个工作脚本来识别图像上的表格。我偶然发现了以下帖子的答案:https://stackoverflow.com/a/51756462/10434683 他正是在做我所需要的。但是,如果我运行此代码,则会收到如下错误:

enter image description here

似乎错误是由boundingRect()函数引起的。 Ive查找了文档,但是没有找到任何有用的信息。

以下是使用boundingRect()的函数...

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

0 个答案:

没有答案