cv.Moments issue with 1st parameter

asked 2013-09-25 15:58:45 -0500

updated 2013-09-25 16:07:41 -0500

berak gravatar image

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 "", 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)



while True:


    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)
edit retag flag offensive close merge delete


looks like the old cv interface only accepts a pointlist, not a binary img.

but please don't waste any energy on this, instead rewrite it using the cv2 api, since cv won't be availyble in the near future.

berak gravatar imageberak ( 2013-09-25 16:25:16 -0500 )edit