dhlab-epfl / dhSegment

Generic framework for historical document processing
https://dhlab-epfl.github.com/dhSegment
GNU General Public License v3.0
370 stars 116 forks source link

Fix cv2.findContours error #44

Closed chenjie closed 4 years ago

chenjie commented 4 years ago

Reference: https://stackoverflow.com/a/25510061/10692493 Error log:

Traceback (most recent call last):
  File "demo.py", line 84, in <module>
    mode='min_rectangle', n_max_boxes=1)
  File "/<internal_dir>/dhSegment/dh_segment/post_processing/boxes_detection.py", line 28, in find_boxes
    contours, _ = cv2.findContours(boxes_mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
ValueError: too many values to unpack (expected 2)

OpenCV version:

$ python
Python 3.7.3 (default, Mar 27 2019, 16:54:48) 
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'3.4.2'
solivr commented 4 years ago

opencv >= 4.0 should be used