title: Are there any libaries to compare a small image to a screen grab and return an x,y coordinate list of where it's located?
body: <p>this is a pretty rough area (fuzzy logic image comparison) that is way
  above my pay grade, so to speak.</p>
  
  <p>I'm trying to write a program that will detect carrots (and other veggies) onscreen from a game and return matching x,y coordinates for each found match. </p>
  
  <p>The intent is to track each time the vegetable grows (5 times) and eventually automate the watering/harvesting of the vegetables (once you see the screenshots this will make more sense).</p>
  
  <p>I tried using the image compare code located at 
  <a href="http://sites.google.com/site/serinolorenzo/blackmask" rel="nofollow">http://sites.google.com/site/serinolorenzo/blackmask</a></p>
  
  <p>it actually works flawlessly when searching this screenshot (and desktop grabs)
  <a href="http://imageshack.us/photo/my-images/24/mac8.png/" rel="nofollow">http://imageshack.us/photo/my-images/24/mac8.png/</a></p>
  
  <p>for instances this image...
  <a href="http://imageshack.us/photo/my-images/249/carrotplant.png/" rel="nofollow">http://imageshack.us/photo/my-images/249/carrotplant.png/</a></p>
  
  <p>It does find and return multiple "Carrot Seeds" menu coordinates.</p>
  
  <p>However when I get down to detecting the veggies (the meat and potatoes of what the compare needs to detect) it fails to find a match.</p>
  
  <p>I've tried various "carrot" screenshot, most recently...
  <a href="http://imageshack.us/photo/my-images/829/carrotlight1t.png/" rel="nofollow">http://imageshack.us/photo/my-images/829/carrotlight1t.png/</a></p>
  
  <p>to the image
  <a href="http://imageshack.us/photo/my-images/408/macnolight1.png/" rel="nofollow">http://imageshack.us/photo/my-images/408/macnolight1.png/</a></p>
  
  <p>(I had to turn in game lighting off when I got here, to ensure colors stayed the same regardless of game time).</p>
  
  <p>I thought (by going over the source code for the image compare) that black would be ignored, so I'm not sure exactly what's going on, but it just will not find a match now, even if I set the thresholds lower.</p>
  
  <p>Are there any (well documented) libraries that exist to do this, as coding it from scratch is just something I can't do at the moment.</p>
  
  <p>Barring that (and if whomever is reading this has the time) can you see where I'm going wrong?</p>
  
  <p>The code I'm using to do the testing is...</p>
  
  <pre><code>    public void tester()
      {
          Bitmap screenshot;
          screenshot = new Bitmap(@"c:\MyMercurial\ATITDVeggieMacro\ATITDVeggieMacro\Images\macnolight1.bmp");
  
          Bitmap searchFor;
          searchFor = new Bitmap(@"c:\MyMercurial\ATITDVeggieMacro\ATITDVeggieMacro\Images\wholecarrot.bmp");
          int ac1;
          int ac2;
  
          ArrayList test = BlackMask.Search(screenshot,searchFor,
              0,10,75,5,80,20,100,true,out ac1,out ac2);
  
          statusUpdate = ac1.ToString()+"good,"+ ac2.ToString()+" bad/ X=";
      }
  </code></pre>
  
  <p>(I just update the file paths when I want to change images).</p>
  
  <p>(Bonus question, how to I use relative paths to tell it to just go up two directories and then down into the Images folder, I can't at all remember the relative path shortcuts)</p>
  
  <p>Thanks for any help guys, this ones got me slamming my forehead. </p>