【问题标题】:OpenCV CvSeq recursive element access fails for large images?大图像的 OpenCV CvSeq 递归元素访问失败?
【发布时间】:2011-09-30 07:34:41
【问题描述】:

我的开发环境是 Windows 7 上的 Mingw32 位 CMake。(同样的代码在 Linux 上运行良好)

我使用 cvFindContours() 来使用 OpenCV 检测轮廓。

我使用递归方法遍历生成的 CvSeq 以逐级访问轮廓,如下所示:

void helperParseCurves(CvSeq* contour, int level) {


    //Travel same level contours
    if(contour->h_next != NULL) {
        helperParseCurves(contour->h_next, level);
    }
    if(contour->v_next != NULL) {
        helperParseCurves(contour->v_next, level+1);
    }
    //Travel child levels
    for(int i=0; i<contour->total; i++){

        //Try to access Point data -- Crash here when threshold level 114 ?
        //Works when uncommented
        CvPoint* p = CV_GET_SEQ_ELEM(CvPoint, contour, i);

    }
}

但应用程序在 CvPoint* p = CV_GET_SEQ_ELEM(CvPoint, contour, i); 行崩溃; 这发生在一些特定的大图像上,并且在 Linux 中运行良好。

我已经上传了一个示例程序来演示场​​景

http://dl.dropbox.com/u/17399055/opencv-test.zip

*使用 CMake 下载和编译

*使用示例图像运行代码 - "OCvTest.exe test-img.tif"

*将滑块值更改为 114 左右,应用程序崩溃。

*如果第 27 行被注释可以正常工作。

有什么建议吗?

这可能是 OpenCV 错误吗?

提前致谢。

【问题讨论】:

    标签: c++ recursion opencv


    【解决方案1】:

    我意识到这是由于递归函数而发生的。一旦我将其设为迭代函数,一切正常。 现在我知道为什么递归函数不好了……之前并没有真正“实际”理解这一点……

    【讨论】:

      猜你喜欢
      • 2017-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-12
      • 2013-07-28
      • 1970-01-01
      • 2011-06-12
      相关资源
      最近更新 更多