title: cvMatchTemplate() function giving assertion failed error? opencv
body: <p>I'm trying to do some image tracking using <code>cvMatchTemplate()</code> but I keep getting an assertion failed error -215. I hope someone can figure this out. I've made sure that all the ivars are not nil and results and templates are sized correctly. I am on opencv 2.2</p>
  
  <pre><code>    int ww = image-&gt;width - template-&gt;width + 1;
      int hh = image-&gt;height - template-&gt;height + 1;
      CvSize tempsize = cvSize(ww, hh);
      IplImage *results = cvCreateImage(tempsize,image-&gt;depth, image-&gt;nChannels);
  
      //set the roi
      cvSetImageROI(image, roiFace);
      cvMatchTemplate(image, template, results, CV_TM_SQDIFF_NORMED);
  </code></pre>
  
  <p>Here's the error: </p>
  
  <pre><code>`OpenCV Error: Assertion failed (
  result.size() == cv::Size(std::abs(img.cols - templ.cols) + 1, std::abs(img.rows - templ.rows) + 1) 
  
  &amp;&amp; 
  result.type() == CV_32F) in 
  
  cvMatchTemplate, file /Volumes/ramdisk/opencv/OpenCV-2.2.0/modules/imgproc/src/templmatch.cpp, line 381
  terminate called after throwing an instance of 'cv::Exception'
  
  
    what():  /Volumes/ramdisk/opencv/OpenCV-2.2.0/modules/imgproc/src/templmatch.cpp:381: error: (-215) result.size() == cv::Size(std::abs(img.cols - templ.cols) + 1, std::abs(img.rows - templ.rows) + 1) &amp;&amp; result.type() == CV_32F in function cvMatchTemplate`
  </code></pre>