2013-03-28 83 views
0

我想在Opencv2.4.4中使用VS2010express(C++)中的findContours函数代码如下。 Mat canny_output; std :: vector>轮廓;在opencv findContours与“System.AccessViolationException”

/// Detect edges using canny 
Canny(src_gray, canny_output, 100, 200, 3); 
/// Find contours 
threshold(canny_output,canny_output,0,255,THRESH_BINARY); 

findContours(canny_output, contours, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE); 

但程序将总是在系统错误System.AccessViolationException的最后一行触发断点。

任何人有任何想法?

回答

0

建议:

  1. 确保contoursvector< vector<Point> >
  2. Canny操作就可以直接喂边缘findContour..why你在做一个阈值后?也就是说,阈值为零...跳过该行...因为canny的输出是二进制图像。
  3. 确保cannny_output也是一个灰色的图像。

编辑:尝试这个..although这给外部contours..check阉findcontour是工作会有或不..

findContours(canny_output,contours,CV_RETR_EXTERNAL,CV_CHAIN_APPROX_NONE,Point())

+0

我已经定义的轮廓作为矢量<矢量>,后我删除阈值线,错误成为“堆被摧毁”,还有什么想法? – 2013-03-28 03:40:21

+0

注释掉findContours并尝试imshow(“CANNY”,canny_output)...检查边缘检测后的图像。 – 2013-03-28 03:55:29

+0

Canny后的图像可以正常输出,但它在findContours – 2013-03-28 04:13:34