Mit drawContours OpenCV-Funktion in python

Habe ich installiert OpenCV 2.2 und wenn ich versuche, mit drawContours bekomme ich die folgende Fehlermeldung:

cv.drawContours(frame, contours, 0, cv.RGB(255, 0, 0))
TypeError: <unknown> is not a numpy array

Den code für diesen Fehler ist der folgende:

storage = cv.CreateMemStorage(0)
contours = cv.FindContours (color_mask, storage, method = cv.CV_CHAIN_APPROX_SIMPLE)
cv.drawContours(frame, contours, 0, cv.RGB(255, 0, 0))

Die python-Dokumentation entspricht nicht mit der richtigen Reihenfolge der Parameter (ich weiß die richtige Reihenfolge zu danken, die im LEERLAUF) und die C++ - Dokumentation für diese Funktion hilft mir nicht sehr viel

Hier ist der vollständige code (relevante code):

    cv.NamedWindow("MyWindow", 1)
    capture = cv.CaptureFromCAM(0)

    while 1:
        frame = cv.QueryFrame(capture)

        color_mask = cv.CreateImage(cv.GetSize(frame), 8, 1)

        cv.InRangeS(frame, cv.Scalar(*min_color), cv.Scalar(*max_color), color_mask)

        cv.CvtColor(frame, frame, cv.CV_BGR2HSV)

        storage = cv.CreateMemStorage(0)
        contours = cv.FindContours (color_mask, storage, method = cv.CV_CHAIN_APPROX_SIMPLE)
        cv.drawContours(image = frame, contours = contours, contourIdx = 0, color = cv.RGB(255, 0, 0))

        cv.ShowImage("MyWindow", frame)

Vielen Dank im Voraus

InformationsquelleAutor Manuel | 2011-04-06
Schreibe einen Kommentar