title: Whenever I use cvMatchTemplate in openCV, I get a segmentation fault. Why?
body: <p>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.</p>
  
  <p>Here is relevant code:</p>
  
  <p>IplImage* imgOriginal = cvLoadImage("reference.png", 0);
   IplImage* imgTemplate = cvLoadImage("template.png", 0);</p>
  
  <p>IplImage* imgResult = cvCreateImage(cvSize(imgOriginal->width-imgTemplate->width+1, imgOriginal->height-imgTemplate->height+1), IPL_DEPTH_32F, 1);
      cvZero(imgResult);</p>
  
  <p>cvMatchTemplate(imgOriginal, imgTemplate, imgResult, CV_TM_CCOEFF_NORMED);
  ...</p>
  
  <p>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. </p>
  
  <p>Does anyone have any ideas on how to fix this?  Thanks a lot in advance. </p>