title: Opencv c++Template/Pattern Matching Scale and Rotation invariant
body: <p>I want to see if a template in present in an image using openCv and c++.  However due to different distance  at which the image is taken and different position of the image, the match does not occur correctly.</p>
  
  <p>here is my code:</p>
  
  <pre><code>IplImage* image    = cvLoadImage("C:/images/Photo0734.jpg", 1);
  IplImage* templat  = cvLoadImage("C:/images/templatecoin.jpg", 1);
  int percent =25;// declare a destination IplImage object with correct size, 
  depth and  channels
  IplImage* image3 = cvCreateImage( cvSize((int)((image-&gt;width*percent)/100) , 
  (int)((image-&gt;height*percent)/100) ),image-&gt;depth, image-&gt;nChannels );
  
  //use cvResize to resize source to a destination image
  cvResize(image, image3);
  IplImage* image2   = cvCreateImage(cvSize(image3-&gt;width, image3-&gt;height), 
  IPL_DEPTH_8U,   1);
  IplImage* templat2 = cvCreateImage(cvSize(templat-&gt;width, 
  templat-&gt;height),   IPL_DEPTH_8U, 1); 
  
  cvCvtColor(image3, image2, CV_BGR2GRAY);
  cvCvtColor(templat, templat2, CV_BGR2GRAY);
  
  
  int w = image3-&gt;width - templat-&gt;width + 1;
  int h = image3-&gt;height - templat-&gt;height + 1;
  result = cvCreateImage(cvSize(w, h), IPL_DEPTH_32F, 1);
  cvMatchTemplate(image2, templat2, result, CV_TM_CCORR_NORMED);
  
  double min_val, max_val;
  CvPoint min_loc, max_loc;
  cvMinMaxLoc(result, &amp;min_val, &amp;max_val, &amp;min_loc, &amp;max_loc);
  
  cvRectangle(image3, max_loc, cvPoint(max_loc.x+templat-&gt;width, 
  max_loc.y+templat-&gt;height), cvScalar(0,1,1), 1);
  
  cvShowImage("src", image3);
  //cvShowImage("result image", result);
  cvWaitKey(0);
  </code></pre>
  
  <p>Please note that I am Unable to use "Mat". Is it possible to use IplImage* and enable the code to be invariant to scaling and rotation? help me.</p>