ValueError: too many values to unpack when running chapter 5 code

185 views
Skip to first unread message

Laurent

unread,
Nov 18, 2016, 6:12:02 PM11/18/16
to OpenCV with Python Blueprints
Hi,

I truely enjoy this book but I got stuck when running some of the code. More precisely, I am working on a multiple object tracking problem and wanted to use the code of chapter 5. Unfortunately, running the chapter5.py returns an error:

Traceback (most recent call last):
  File "chapter5.py", line 53, in <module>
    main()
  File "chapter5.py", line 44, in main
    sal.get_proto_objects_map(use_otsu=False)))
  File "/Users/Anyon/Projects/cvproj/opencv_blueprints_code/opencv-python-blueprints/chapter5/tracking.py", line 68, in advance_frame
    box_all = self._append_boxes_from_saliency(proto_objects_map, box_all)
  File "/Users/Anyon/Projects/cvproj/opencv_blueprints_code/opencv-python-blueprints/chapter5/tracking.py", line 105, in _append_boxes_from_saliency
    cnt_sal, _ = cv2.findContours(proto_objects_map, 1, 2)
ValueError: too many values to unpack

I stepped throught the code but have not been able to spot what the issue is. Any pointers would be much appreciated.

Thanks 

Laurent

Michael Beyeler

unread,
Nov 29, 2016, 12:52:07 AM11/29/16
to OpenCV with Python Blueprints
Hi Laurent,

Thanks for your comment! I'm glad you're enjoying the book.
Any chance you're using OpenCV's master branch? I believe the syntax for the findContours command has recently changed. Try this:

_, cnt_sal, _= cv2.findContours(proto_objects_map, 1, 2)

More info here:

All the best,
Michael
Reply all
Reply to author
Forward
0 new messages