title: OpenCV (emgu) don't detect the good form
body: <p>I'm trying to learn OCR processing. I have decided to create a .net project which use EmguCv wrapper to use OpenCV library.</p>
  
  <p>I have wrote a little piece of code (most of lines come from <a href="https://stackoverflow.com/questions/16406958/emgu-finding-image-a-in-image-b">here</a>) :</p>
  
  <pre><code>    public static Image&lt;Bgr, byte&gt; FindImage(string Imgtemplate, string Imgsource, float coeff)
      {
          Image&lt;Bgr, byte&gt; source = new Image&lt;Bgr, byte&gt;(Imgsource); // Image B
          Image&lt;Bgr, byte&gt; template = new Image&lt;Bgr, byte&gt;(Imgtemplate); // Image A
          Image&lt;Bgr, byte&gt; imageToShow = source.Copy();
  
          using (Image&lt;Gray, float&gt; result = source.MatchTemplate(template, Emgu.CV.CvEnum.TemplateMatchingType.CcoeffNormed))
          {
              double[] minValues, maxValues;
              //double minValues = 0, maxValues = 0;
              Point[] minLocations, maxLocations;
              //Point minLocations = new Point(), maxLocations = new Point();
              //CvInvoke.Normalize(result, result, 0, 1, Emgu.CV.CvEnum.NormType.MinMax, Emgu.CV.CvEnum.DepthType.Default, new Mat());
              //CvInvoke.MinMaxLoc(result, ref minValues, ref maxValues, ref minLocations, ref maxLocations, new Mat());
              result.MinMax(out minValues, out maxValues, out minLocations, out maxLocations);
  
              // You can try different values of the threshold. I guess somewhere between 0.75 and 0.95 would be good.
              if (maxValues[0] &gt; coeff)
              {
                  // This is a match. Do something with it, for example draw a rectangle around it.
                  Rectangle match = new Rectangle(maxLocations[0], template.Size);
                  //Rectangle match = new Rectangle(maxLocations, template.Size);
                  imageToShow.Draw(match, new Bgr(Color.Green), 1);
              }
          }
  
          // Show imageToShow in an ImageBox (here assumed to be called imageBox1)
          //imageBox1.Image = imageToShow;
          return imageToShow;
  
      }
  </code></pre>
  
  <p>The source image is : </p>
  
  <p><a href="https://i.stack.imgur.com/6yYyT.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6yYyT.jpg" alt=""></a></p>
  
  <p>The template image is :</p>
  
  <p><a href="https://i.stack.imgur.com/Mn9R4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Mn9R4.png" alt=""></a></p>
  
  <p>Both images are jpg. The result (with 100 % match) of the method is :</p>
  
  <p><a href="https://i.stack.imgur.com/IAykc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IAykc.png" alt=""></a></p>
  
  <p>As you can see the result isn't the good one :/. However, when i run my method with the example given on OpenCV site I have a good result (67 % match) :</p>
  
  <p><a href="https://i.stack.imgur.com/pmXxr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pmXxr.png" alt=""></a></p>
  
  <p>Anyone have an idea about my problem ?
  For the OpenCV example result is there any way to improve the matches percent ? Which option/parameter is the best ?</p>