[英]OpenCV using command line argument for input image (Python)
I am trying to load an image from a file specified on the command line then process it using the OpenCV command HoughCircles. 我正在尝试从命令行上指定的文件加载图像,然后使用OpenCV命令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. 但是,如果我直接加载文件,即将argv [0]更改为显式文件名,则一切正常。 Any ideas?
有任何想法吗?
In python and most other languages argv[0]
contains the program name. 在python和其他大多数语言中,
argv[0]
包含程序名称。 Try using argv[1]
to get the correct result. 尝试使用
argv[1]
获得正确的结果。
Here is some Python Documentation to help you. 这是一些Python文档可以为您提供帮助。 Python has an amazing library of documentation I highly recommend using it.
Python拥有一个很棒的文档库,我强烈建议您使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.