views:

38

answers:

1

Hey guys and gals,

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, imgTemplate, 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.

A: 

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

Ian Wetherbee