Wie zu erkennen und zeichnen Konturen mit OpenCV in Python?

Schrieb ich den folgenden code zu erkennen und zeichnen Konturen:

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, die ich erhielt:

Traceback (most recent call last):
Datei "C:/Users/R.K.singh/Desktop/Image processing/intro-to-contours.py", line 10, in
Konturen,Hierarchie = cv2.findContours(dreschen,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE);
ValueError: zu viele Werte zu entpacken

Was ist falsch? Ich bin mit Python 2.7 und OpenCV 3.1.0

InformationsquelleAutor singhuist | 2017-01-05
Schreibe einen Kommentar