【发布时间】:2011-03-28 01:46:54
【问题描述】:
我使用 pyopencv 查找轮廓,但无法绘制找到的轮廓。我得到了错误:
23 color = Scalar(255) 24 print type(color)---> 25 drawContours(img, list(contours), -1, color) 26 27 imshow('Xe may - 0', img)
ArgumentError:Python 参数类型 在 pyopencv.pyopencvext.drawContours(垫, list, int, Scalar) 与 C++ 不匹配 签名: drawContours(cv::Mat {lvalue} 图像, 标准::向量, 标准::分配器 > >, 标准::分配器, 标准::分配器 > > > > 轮廓,int轮廓Idx, cv::Scalar_ 颜色,整数 厚度=1,int lineType=8, 标准::向量, 标准::分配器 >> 层次结构=vector_Vec4i(len=0, []), int maxLevel=2147483647, cv::Point_ 偏移量=Point2i(x=0, y=0)) 警告: 执行文件失败:
这是我的代码
# load image
img = imread('37S2231.jpg')
# gray scale
out = img.clone()
cvtColor(img, out, CV_RGB2GRAY)
# equalizes the histogram of a grayscale image
# increases the contrast of the image
out2 = out.clone()
equalizeHist(out, out2)
# canny to extract edges
out3 = out2.clone()
Canny(out2, out3, 150, 200)
# threshold
out4 = out3.clone()
threshold(out3, out4, 254, 255, THRESH_BINARY)
# contours
contours = findContours(out4, 1, 1)
print type(contours)
color = Scalar(255)
print type(color)
drawContours(img, list(contours), -1, color)
我检查了http://packages.python.org/pyopencv/2.1.0.wr1.0.2/ 的drawContours 函数,但它看起来与我的代码相似。我是不是做错了什么?
谢谢
【问题讨论】:
标签: opencv