OpenCV Python HoughCircles error

Posted by Dan on Stack Overflow See other posts from Stack Overflow or by Dan
Published on 2010-05-29T00:38:08Z Indexed on 2010/05/29 0:42 UTC
Read the original article Hit count: 601

Filed under:
|
|

Hi,

I'm working on a program that detects circular shapes in images. I decided a Hough Transform would be the best, and I found one in the OpenCV library. The problem is that when I try to use it I get an error that I have no idea how to fix. Is OpenCV for Python not fully implemented? Is there a fix to the library I need for the program to work?

Here's the code:

import cv

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

while True:
    img = cv.QueryFrame(capture)
    gray = cv.CreateImage(cv.GetSize(img), 8, 1)
    edges = cv.CreateImage(cv.GetSize(img), 8, 1)

    cv.CvtColor(img, gray, cv.CV_BGR2GRAY)
    cv.Canny(gray, edges, 50, 200, 3)
    cv.Smooth(gray, gray, cv.CV_GAUSSIAN, 9, 9)

    storage = cv.CreateMat(1, 2, cv.CV_32FC3)

    #This is the line that throws the error
    cv.HoughCircles(edges, storage, cv.CV_HOUGH_GRADIENT, 2, gray.height/4, 200, 100)

    #cv.ShowImage("camera", img)
    if cv.WaitKey(10) == 27:
         break

And here is the error I'm getting:

OpenCV Error: Null pinter () in unknown function, file ..\..\..\..\ocv\openc\src\cxcore\cxdatastructs.cpp, line 408 Traceback (most recent call last): File "ellipse-detect-webcam.py", line 20, in cv.HoughCircles(edges, storage, cv.CV_HOUGH_GRADIENT, 2, gray.height/4, 200, 100) cv.error

Thanks in advance for the help.

© Stack Overflow or respective owner

Related posts about python

Related posts about opencv