Skip to content

fix findContours outputs#3

Open
nagahamanil wants to merge 1 commit intooreilly-japan:masterfrom
nagahamanil:master
Open

fix findContours outputs#3
nagahamanil wants to merge 1 commit intooreilly-japan:masterfrom
nagahamanil:master

Conversation

@nagahamanil
Copy link

付録Aのauto_coloring.ipynbを実行すると
p.391の部分で下記エラーが発生しております。


ValueError Traceback (most recent call last)
in
1 _, contours, _ = cv2.findContours(gray_image, cv2.RETR_TREE,
----> 2 cv2.CHAIN_APPROX_SIMPLE)
3 for i,cnt in enumerate(contours):
4 gray_image = cv2.drawContours(gray_image, [cnt], 0, i+1, cv2.FILLED)
5

ValueError: not enough values to unpack (expected 3, got 2)

findContours

findContoursの戻り値を修正することでエラーが発生しなくなりましたので
お手すきの際にご確認お願いします。

@aizoaikawa
Copy link
Collaborator

ご指摘ありがとうございます。
OpenCV4から cv2.findContours の返り値が3つから2つに変わりました。本書はOpenCV3を用いていますので、当面このままとさせていただきますが、OpenCV4の普及を見て、ほかのライブラリのバージョンと合わせて修正させていただきます。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants