【发布时间】:2018-07-15 16:04:31
【问题描述】:
我对本教程有疑问:https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_imgproc/py_contours/py_contour_features/py_contour_features.html 确实,当我尝试执行此代码时遇到此错误:
import numpy as np
import cv2
img = cv2.imread("onepoint.png", 0)
canny_img = cv2.Canny(img,150,200)
ret,thresh = cv2.threshold(canny_img,127,255,0)
contours,hierarchy = cv2.findContours(thresh, 1, 2)
cnt = contours[0]
M = cv2.moments(cnt)
print M
这是错误:
File "contours.py", line 13, in <module>
contours,hierarchy = cv2.findContours(thresh, 1, 2)
ValueError: too many values to unpack
我不明白为什么会出现这个错误。我知道cv2.findContours (thresh, 1, 2) 会返回给我 3 个“数组”,但是为什么呢?如果有人好心向我解释我是一个接受者:(
我正在尝试构筑这个picture 的文字。
我是 OpenCV 的新手,我想你会明白的,
提前致谢
【问题讨论】:
-
我在发布我的问题之前查看了此链接,但我没有找到明确的解释..
标签: python opencv image-processing opencv-contour