在opencv 2.2 中 调用 findContours() 函数 Crash 问题

    技术2022-05-19  28

     

    在vc2010中创建的dll中调用findContours()函数,系统崩掉!

     

    代码如下:

           vector<vector<cv::Point> > contours;

           vector<Vec4i> hierarchy;

           findContours(bin, contours, hierarchy,

               CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE );

     

     

    分析opencv源代码,跟踪测试

    进入工程:opencv_imgproc

     发现findContours函数 是调用 _findContours函数来实现的,跟踪进去,发现contours.resize(total) 就会失败崩溃,应该是系统DLL调用配置问题,进一步不知道原因了

     

    解决方案:

    直接将:_findContours( Mat& image, vector<vector<Point> >& contours,

                   vector<Vec4i>* hierarchy, int mode, int method, Point offset )

    提出来,放到dll中改一个名字,再调用OK了。

     

        呵呵,用了一天时间才解决了问题,开始一直找动态库配置原因,后面又重新下载源代码编译跟踪分析出问题源头,先临时解决了。

        应该还有更好的解决方案,应该是参数传递问题,有牛人给些建议


    最新回复(0)