Ich schrieb den folgenden Code Konturen zu erkennen und zeichnen:Wie erkennen und zeichnen Sie Konturen mit OpenCV in Python?
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);
Und hier ist der Fehler, den ich erhalten:
Traceback (most recent call last): File "C:/Users/R.K.singh/Desktop/Image processing/intro-to-contours.py", line 10, in contours,hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE); ValueError: too many values to unpack
Was ist falsch? Ich verwende Python 2.7 und OpenCV 3.1.0
was ist scharf? Es ist nicht in meinem Code definiert. @ selçuk-İlhan-aydi – singhuist
Ich habe den Code bearbeitet –