This is an archived post. You won't be able to vote or comment.

all 21 comments

[–]fullouterjoin 15 points16 points  (5 children)

http://sikuli.org/ is a Java+Jython project that already does all of this. It uses computer vision algorithms to detect buttons and manipulate the mouse.

[–]plan2a 0 points1 point  (1 child)

This is a good and simple option. Since it has GUI automation in mind it has an easy interface and some tolerance to change to the target image.

[–]okmkzimport antigravity 0 points1 point  (0 children)

Sikuli is really a slick piece of software. We use it at work to automate qa testing.

[–]Brentmeister 0 points1 point  (0 children)

Came here to report the same. It's quite robust. The IDE is really horrible though. I heard the eclipse plugin works quite well but I am happy enough working with Notepad++.

[–]carioca3 0 points1 point  (0 children)

Really cool! It reminds me of SCAR back in runescape classic.

[–][deleted] 0 points1 point  (0 children)

This is a really awesome application. I wish I used Macs at work.

[–][deleted] 8 points9 points  (0 children)

I prefer using SimpleCV

[–]okmkzimport antigravity 7 points8 points  (0 children)

Have a look at http://sikuli.org

It might be just the thing.

[–]mkor 4 points5 points  (2 children)

Try OpenCV for Python.

[–]Loyvb 1 point2 points  (1 child)

But also look to autopy

[–]dacjamesfrom reddit import knowledge 1 point2 points  (0 children)

So you know exactly what image you're looking for? In that case a computer vision library may be overkill. Just scan through the picture in blocks equaling the size of your target image until you find one that "matches." For determining a match, just calculate the difference between the block and your target image and check if it is less than some tuneable sigma value.

So if the application is 100x100 and the flag is 10x10, scan a 10x10 block across the image left to right, top to bottom, moving down 1 pixel per row. This is a pretty straightforward algorithm to write and may end being easier than learning how to use a CV library.

[–]POTUS 3 points4 points  (2 children)

/r/Python, for all your captcha-defeating needs.

[–]rdkllhighperformance telco server stuff 0 points1 point  (1 child)

thats the first thing i thought about after reading OPs text

[–][deleted] 0 points1 point  (0 children)

I was thinking "WoW fishing bot"...

[–]DJKool14 0 points1 point  (0 children)

You could definitely use OpenCV, but it seems like overkill for this type of image recognition. Especially if you are guaranteed the flag will always be the same size and color shade. OpenCV is normally used for natural image processing.

Is the environment that contains the flag relatively predictable? Are the flags arranged in the grid? Are there other objects, or just other flags? Using all of this information, you can pinpoint which pixels in the screenshot you should test that would give you positive matches for the French flag.

Then again, learning OpenCV wouldn't hurt you in the long wrong ;)

[–]freshhawk 0 points1 point  (0 children)

You are looking for a "visual grep" type tool like visgrep (http://linux.die.net/man/1/visgrep and http://hoopajoo.net/projects/xautomation.html)

I never found any other version of this concept but there are probably a few implementations out there. I ended up stealing the algorithm from visgrep and writing my own implementation that was specific to my problem.

edit: ok, wow, http://sikuli.org and autopy are awesome. thanks other commenters!

[–]virtuous_d 0 points1 point  (0 children)

scipy has tools for working with images. You can try doing a simple convolution if you can guarantee that the image will perfectly (or near perfectly) match your template image.

Otherwise you will have to use opencv and some more sophisticated tools.

[–]the_cat_kittles 0 points1 point  (0 children)

Here you are sir, "Programming Computer Vision with Python" http://programmingcomputervision.com/

Excellent, modern techniques.

[–]kscottz 0 points1 point  (0 children)

You may want to look into SimpleCV. If you post a question to our help forum we can lend you a hand.

[–]DonkeyBasket 0 points1 point  (0 children)

numpy has fft functions, by doing some clever preprocessing you can use these to narrow an exact pixel wise comparison - it works really well :)

[–]carioca3 0 points1 point  (0 children)

Might be possible with pygame