this is a pretty rough area (fuzzy logic image comparison) that is way above my pay grade, so to speak.
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.
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).
I tried using the image compare code located at http://sites.google.com/site/serinolorenzo/blackmask
it actually works flawlessly when searching this screenshot (and desktop grabs) http://imageshack.us/photo/my-images/24/mac8.png/
for instances this image... http://imageshack.us/photo/my-images/249/carrotplant.png/
It does find and return multiple "Carrot Seeds" menu coordinates.
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.
I've tried various "carrot" screenshot, most recently... http://imageshack.us/photo/my-images/829/carrotlight1t.png/
to the image http://imageshack.us/photo/my-images/408/macnolight1.png/
(I had to turn in game lighting off when I got here, to ensure colors stayed the same regardless of game time).
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.
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.
Barring that (and if whomever is reading this has the time) can you see where I'm going wrong?
The code I'm using to do the testing is...
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=";
}
(I just update the file paths when I want to change images).
(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)
Thanks for any help guys, this ones got me slamming my forehead.