title: iphone opencv - template matching
body: <p>i've implemented this OpenCV build into my iphone project:</p>
  
  <p><a href="http://aptogo.co.uk/2011/09/opencv-framework-for-ios/" rel="nofollow noreferrer">http://aptogo.co.uk/2011/09/opencv-framework-for-ios/</a></p>
  
  <p>It builds successfully and i know how to capture an image with my camera, grayscale it and show it on an imageview.</p>
  
  <p>But what i'd like to do is templatematching with the image that i captured (with the camera) against an template image.</p>
  
  <p>I have both images grayscaled, but i just don't get how the 'matchTemplate' works. This is what i have so far:</p>
  
  <pre><code>cv::Mat grayFrame, grayImg, output;
  
  // This is the template image which i store in a cv::Mat and
  // after that i grayscale the image
  UIImage *testImage = [UIImage imageNamed:@"qr.png"];
  cv::Mat tempMat = [testImage CVMat];
  cv::cvtColor(tempMat, grayImg, cv::COLOR_RGB2GRAY);
  
  
  // Convert captured frame to grayscale
  cv::cvtColor(_lastFrame, grayFrame, cv::COLOR_RGB2GRAY);
  
  // Having trouble here...
  cv::matchTemplate(grayFrame, grayImg, output, CV_TM_CCORR_NORMED);
  
  
  // Display result
  // This already works for both the captured image and the template image
  camView.image = [UIImage imageWithCVMat:grayFrame];
  </code></pre>
  
  <p>The problem with this code is, is this line:</p>
  
  <p>cv::matchTemplate(grayFrame, grayImg, output, 1);</p>
  
  <p>I'm not sure if i'm doing it right. Because i don't get a result back in 'output' like "MinMax" to get the positions of the found match... Am i even passing the right variables to the matchTemplate function...??</p>
  
  <p>Anyway, can someone please tell me what i'm doing wrong and how to make this work?</p>
  
  <ul>
  <li>edit - 
  Added a screenshot of my variable 'output'
  <img src="https://i.stack.imgur.com/R5sWO.png" alt="enter image description here"></li>
  </ul>
  
  <p>Thanks for any help!</p>