Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm answering my question since I've found the solution:</p> <p><a href="https://stackoverflow.com/questions/2472467/how-to-find-one-image-inside-of-another?lq=1">this</a> worked out for me:</p> <pre><code>System.Drawing.Bitmap sourceImage = (Bitmap)Bitmap.FromFile(@"C:\SavedBMPs\1.jpg"); System.Drawing.Bitmap template = (Bitmap)Bitmap.FromFile(@"C:\SavedBMPs\2.jpg"); // create template matching algorithm's instance // (set similarity threshold to 92.5%) ExhaustiveTemplateMatching tm = new ExhaustiveTemplateMatching(0.921f); // find all matchings with specified above similarity TemplateMatch[] matchings = tm.ProcessImage(sourceImage, template); // highlight found matchings BitmapData data = sourceImage.LockBits( new Rectangle(0, 0, sourceImage.Width, sourceImage.Height), ImageLockMode.ReadWrite, sourceImage.PixelFormat); foreach (TemplateMatch m in matchings) { Drawing.Rectangle(data, m.Rectangle, Color.White); MessageBox.Show(m.Rectangle.Location.ToString()); // do something else with matching } sourceImage.UnlockBits(data); </code></pre> <p>The only problem was it was finding all (58) boxes for said game. But changing the value 0.921f to 0.98 made it perfect, i.e. it finds only the specified number's image (template)</p> <p><strong>Edit</strong>: I actually have to enter different similarity thresholds for different pictures. I found the optimized values by trying, in the end I have a function like</p> <pre><code>float getSimilarityThreshold(int number) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload