輪郭を検出して描画するために、次のコードを作成しました。
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 を使用しています