我编写了以下代码来检测和绘制轮廓:
img = cv2.imread('test2.tif');
if not img is None:
imgray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY);
ret,thresh = cv2.threshold(imgray,127,255,0);
contours,hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE);
#draw a three pixel wide outline
cv2.drawContours(img,contours,-1,(0,255,0),3);
这是我收到的错误:
回溯(最近一次调用最后):文件“C:/Users/RKsingh/Desktop/Image processing/intro-to-contours.py”,第 10 行,在轮廓中,层次结构 = cv2.findContours(thresh,cv2.RETR_TREE,cv2 .CHAIN_APPROX_SIMPLE); ValueError:解包的值太多
怎么了?我正在使用 Python 2.7 和 OpenCV 3.1.0