开发者

Whenever I use cvMatchTemplate in openCV, I get a segmentation fault. Why?

I'm trying to do a simple template match in openCV and at the line in my code where I call cvMatchTemplate, I get a segmentation fault. I don't know if this is relevant, but i'm on a mac using x11 and i'm using opencv 2.0.0.

Here is relevant code:

IplImage* imgOriginal = cvLoadImage("reference.png", 0); IplImage* imgTemplate = cvLoadImage("template.png", 0);

IplImage* imgResult = cvCreateImage(cvSize(imgOriginal->width-imgTemplate->width+1, imgOriginal->height-imgTemplate->height+1), IPL_DEPTH_32F, 1); cvZero(imgResult);

cvMatchTemplate(imgOriginal, imgTe开发者_如何学Gomplate, imgResult, CV_TM_CCOEFF_NORMED); ...

I copied this code from a really good tutorial I found online and it seemed like things should work out, but I can't seem to get it. Also, the last parameter in cvMatchTemplate can vary based on how we want to compute the matching and I've tried them all and they call create a segementation fault.

Does anyone have any ideas on how to fix this? Thanks a lot in advance.


Without seeing a real backtrace (try running with gdb), it's hard to tell. Check that imgOriginal and imgTemplate aren't null?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜