在opencv中用“查找”查找对象;System.AccessViolationException“;

在opencv中用“查找”查找对象;System.AccessViolationException“;,opencv,image-processing,visual-studio-2010,Opencv,Image Processing,Visual Studio 2010,我正在尝试将Opencv2.4.4中的FindOntours函数与VS2010express(C++)一起使用。代码如下。 Mat-canny_输出; std::vector>等高线 /// Detect edges using canny Canny( src_gray, canny_output, 100, 200, 3 ); /// Find contours threshold(canny_output,canny_output,0,255,THRESH_BINARY); findCo

我正在尝试将Opencv2.4.4中的FindOntours函数与VS2010express(C++)一起使用。代码如下。 Mat-canny_输出; std::vector>等高线

/// 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

有人知道吗?

建议:

  • 确保
    等高线
    向量
  • 经过一次精明的操作后,你可以直接将边缘送入findContour。你为什么要做阈值分割?阈值为零时也是如此……跳过该行……因为canny的输出是一个二进制图像
  • 确保
    cannny\u输出也为灰色图像
  • 编辑:尝试此..尽管这会给出外部轮廓..检查findcontour是否正常


    findContours(canny\u输出、等高线、CV\u RETR\u外部、CV\u CHAIN\u近似无、Point())

    我已经将等高线定义为vector,删除阈值行后,错误变成“堆被破坏”,还有其他想法吗?请注释findContours并尝试imshow(“canny”,canny\u输出)…检查边缘检测后的图像。canny后的图像可以正常输出,但它在FindContour崩溃了带点的图像不工作。我查看了findContours函数,发现以下内容将导致崩溃:_cours.create(total,1,0,-1,true);