Ask Your Question

Johnnyappseed's profile - activity

2013-09-25 15:58:45 -0600 asked a question cv.Moments issue with 1st parameter

Hello, I have cut down my code to show the goal and where I am having the issue. The first parameter of cv.Moments request an "array – Raster image (single-channel, 8-bit or floating-point 2D array) or an array ( 1 \times N or N \times 1 ) of 2D points (Point or Point2f )." I am feeding it an 8-bit, single channel image. When the code is executed it runs an error of:

"Traceback (most recent call last): File "untitled.py", line 19, in <module> moments = cv.Moments(thresholded_image, 0) TypeError: Argument 'ΣSⁿ☺¿╦≡☺░▓≡☺@Ω,☻ m∩☺    ' must be CvSeq, CvArr, or a sequence of numbers" Ultimately I am trying to track the color black.


import cv

cv.NamedWindow('a_window', cv.CV_WINDOW_AUTOSIZE)

capture=cv.CaptureFromCAM(0)

cv.WaitKey(2)

while True:

    image=cv.QueryFrame(capture)

    hsv_image = cv.CreateImage(cv.GetSize(image), 8, 3) 
    cv.CvtColor(image, hsv_image, cv.CV_BGR2HSV)

    thresholded_image = cv.CreateImage(cv.GetSize(hsv_image), 8, 1)
    #cv.InRangeS(hsv_image, (0, 0, 0), (180, 255, 80), thresholded_image)

    moments = cv.Moments(thresholded_image, 0)
    #area = cv.GetCentralMoment(moments, 0, 0)