Windows触发了一个断点opencv vs2010

时间:2013-11-29 15:55:16

标签: c++ opencv hough-transform

底部的代码给出了结果:

result http://oi42.tinypic.com/vhukj6.jpg

按下某个键时,会显示一条错误消息:

error http://oi39.tinypic.com/2n1gkkm.jpg

我该如何解决这个问题?使用MFC作为静态库,在VS2010 Win8和WinXp上进行了测试 EDIT1:在两种情况下,目标平台都是Win32
EDIT2:当使用MFC切换到“使用标准Windows库”时,Win8上的问题消失了。在WinXp上,它提供访问冲突并指向free.c:retval = HeapFree(_crtheap,0,pBlock);
EDIT3:使用Opencv 2.4.7

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

using namespace cv;

int mindistance = 50; // minimum distance between 2 circle centres       
int hi = 255, lo = 20; //the maximum and minimum radius of the circles


int main(int argc, char* argv[]) {

Mat orig = imread(argv[1]);
Mat display = orig.clone();
Mat snooker, edges;
cvtColor(orig, snooker, CV_RGB2GRAY);
Canny(snooker, edges, 20, 50, 3);
vector<Vec3f> circles;

HoughCircles(edges, circles, CV_HOUGH_GRADIENT, 1, mindistance, hi, lo);

for( size_t i = 0; i < circles.size(); i++ ) 
{

    Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
    int radius = cvRound(circles[i][2]);
    if (radius < (min(snooker.rows, snooker.cols)/10) ) 
        continue;

    // draw the green circle center
    circle( display, center, 3, Scalar(0,255,0), -1, 8, 0 );

    // draw the blue circle outline
    circle( display, center, radius, Scalar(255,0,0), 3, 8, 0 );

}

imshow( "circles", display );
imshow("snooker", snooker);
imshow("edges", edges);
waitKey();

return 0;

}

1 个答案:

答案 0 :(得分:0)

类似于OpenCV Unresolved External Symbols - Other Libraries Needed?

因为您使用MFC作为静态库,所以应该在/ staticlib中添加.lib而不是/ lib

例如&#34; opencv \ build \ x86 \ vc10 \ staticlib&#34;

并添加以下附加.lib

(in /staticlib but not in /lib,example for debug version as 'd' before '.lib')
libpngd.lib
libtiffd.lib
zlibd.lib
IlmImfd.lib
libjasperd.lib
libjpegd.lib

(part of mfc i thought)
comctl32.lib
gdi32.lib
vfw32.lib

根据https://stackoverflow.com/a/21946953/3800477