c++ - OpenCV 找到轮廓 : no matching function

标签 c++ opencv contour

我正在尝试在特定场景中使用 Hough 线,并且一直收到 findContours 方法的无匹配函数错误

代码

...
Mat bw, hsvdst;
...
bw = Mat::zeros(hsvdst.rows, hsvdst.cols, CV_8UC1);
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
findContours(bw.clone(), contours, hierarchy, RETR_EXTERNAL, CHAIN_APPROX_SIMPLE);

错误

error: no matching function for call to ‘findContours(cv::Mat, st
d::vector<std::vector<cv::Point_<int> > >&, std::vector<cv::Vec<int, 4> >&, cv::<anonymous enum>, cv::<anonymous enum>)

note: candidates are:
void cv::findContours(cv::InputOutputArray, cv::OutputArrayOfArr
ays, cv::OutputArray, int, int, cv::Point)
note:   no known conversion for argument 1 from ‘cv::Mat’ to ‘cv::Inpu
tOutputArray {aka const cv::_OutputArray&}’

请帮忙,我不确定我在这里遗漏了什么。

环境:OpenCV 2.4.6.1; Eclipse CDT,Ubuntu 12.04.2

最佳答案

我通过替换来解决

findContours(bw.clone(), contours, hierarchy, RETR_EXTERNAL, CHAIN_APPROX_SIMPLE);

Mat m = bw.clone(); findContours(m, contours, hierarchy, RETR_EXTERNAL, CHAIN_APPROX_SIMPLE);

这有点奇怪,因为 definition findContour 的第一个参数是映射到 Map 类型的 InputOutputArray 类型,并且 clone 方法也返回 Mat 类型。

关于c++ - OpenCV 找到轮廓 : no matching function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18289413/

相关文章:

C++ 运算符重载称为函数

c++ - 为什么在将字符串类型转换为 DWORD 时在运行时得到不同的值?

c++ - 如何通过 Google 测试捕捉断言?

c++ - 使用 opencv2 加载图像时 OpenCv 未处理的异常

python-3.x - 需要帮助找到 2 个单独的轮廓而不是 MICR 代码中的组合轮廓

opencv - 从图像中删除所有轮廓

c++ - 当c++模板定义带有=时是什么意思

opencv - 在 JavaCV 或 OPENCV 中查找轮廓

python - with()语句从opencv中的VideoCapture读取?

r - 将 ggplot2 轮廓从其他方面移动到主方面