1

I am trying to load an image from a file specified on the command line then process it using the OpenCV command HoughCircles. What happens is that I am opening the file:

img = cv2.imread(argv[0],0)

Then trying to use the following function:

def _getCircles(img):
  _circles = cv2.HoughCircles(img,cv2.cv.CV_HOUGH_GRADIENT,1,20,param1=50,param2=30,minRadius=1,maxRadius=20)

But returns the error:

cv2.error: error: (-206) Unrecognized or unsupported array type in function cvGetMat

However if I load the file directly ie change argv[0] to the explicit filename everything works perfectly. Any ideas?

1 Answer 1

6

In python and most other languages argv[0] contains the program name. Try using argv[1] to get the correct result.

Here is some Python Documentation to help you. Python has an amazing library of documentation I highly recommend using it.

Sign up to request clarification or add additional context in comments.

2 Comments

this is my fault for not explaining it right. I know about argv i was passing arguments from __main to def main(argv) via (sys.argv[1:]). Problem was silly using -t instead of -i for command line input. Technically your answer for the question I posed is correct but its my fault for not asking things properly
@MattStokes Shame I wasn't of use but I'm glad you found and fixed the problem anyway.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.