rbaguila / document-layout-analysis

A simple document layout analysis using Python-OpenCV
121 stars 41 forks source link

too many values to unpack #1

Open ghost opened 6 years ago

ghost commented 6 years ago

@rbaguila when running python main.py I get an error:

home@home-lnx:~/Desktop/document-layout-analysis-master$ python main.py 
Traceback (most recent call last):
  File "main.py", line 125, in <module>
    output1_letter = process_letter(th1,output1_letter)
  File "main.py", line 49, in process_letter
    (contours, _) = cv2.findContours(letter_img.copy(), cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
ValueError: too many values to unpack (expected 2)
ogienma commented 5 years ago

Looks like the cv2.findContours return value has changed since this module was written. To get around it, add a new _ value - whenever you see this:

(contours, _) = cv2.findContours(whatever)

change it to this:

(_, contours, _) = cv2.findContours(whatever)