有人可以告诉我这里出了什么问题吗?
line 11, in <module>
im2, contours, hierarchy = cv2.findContours(thresh, 1, 2)
ValueError: not enough values to unpack (expected 3, got 2)
码:
import cv2 as cv
import cv2
filename = "C:\\Users\\Tony\\Pictures\\img807.tif"
img = cv.imread(filename, 0)
ret, thresh = cv.threshold(img, 127, 255, 0)
im2, contours, hierarchy = cv2.findContours(thresh, 1, 2)
cnt = contours[0]
M = cv.moments(cnt)
print(M)
exit()
cv2.findContours
返回两个值(轮廓和层次结构),而不是三个。
因此它解决了错误替换为:
contours, hierarchy = = cv2.findContours(thresh, 1, 2)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句