【问题标题】:findContours in opencv with "System.AccessViolationException"在opencv中找到带有“System.AccessViolationException”的轮廓
【发布时间】:2013-03-28 02:05:12
【问题描述】:

我正在尝试将 Opencv2.4.4 中的 findContours 函数与 VS2010express(C++) 一起使用,代码如下。 垫 canny_output; 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 的最后一行触发断点。

有人知道吗?

【问题讨论】:

    标签: opencv image-processing visual-studio-2010


    【解决方案1】:

    建议:

    1. 确保contoursvector< vector<Point> >
    2. 经过 Canny 操作后,您可以直接将边缘提供给 findContour..为什么要进行阈值处理?阈值也为零...跳过该行...因为 canny 的输出是二进制图像。
    3. 确保cannny_output 也是灰色图像。

    编辑:试试这个..虽然这给出了外部轮廓..检查 findcontour 是否正常..

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

    【讨论】:

    • 我已经将轮廓定义为vector >,删除阈值线后,错误变为“堆被破坏”,还有什么想法吗?
    • 注释掉 findContours 并尝试 imshow("CANNY",canny_output)...检查边缘检测后的图像。
    • canny之后的图片可以正常输出,但是在findContours处崩溃了
    • 带点的那个不行。我查看了 findContours 函数,发现以下会导致崩溃:_contours.create(total, 1, 0, -1, true);
    猜你喜欢
    • 2018-11-19
    • 2019-01-15
    • 1970-01-01
    • 2012-01-16
    • 2011-11-27
    • 1970-01-01
    • 2023-03-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多