1

I have to develop some kind of bot for a testing background with Java. We used Selenium for all the web stuff, and outside the browser: Pixel recognition; that is, taking a screenshot, then compare it with a image I have already, and get the coordinates of where that pattern is on the screenshot.

Any Framework or free Java libraries that could make this job easier?

Thanks in advance!

Emiliano
  • 185
  • 1
  • 12
  • There is a similar question on SO : http://stackoverflow.com/questions/4328187/image-comparison-techniques-with-java – chepseskaf Sep 21 '11 at 12:40

2 Answers2

0

You could read this simple example.

chepseskaf
  • 664
  • 2
  • 12
  • 41
0

You could probably get the following to work:

  • Use java.awt.Robot to take a screen capture as a BufferedImage
  • Convert the BufferedImage to a byte array
  • Do a standard string matching search to locate the pattern in the byte array. Even a naive string search (i.e. checking for the pattern at every possible location) could well be fast enough.
  • Convert the position in the byte array back to image co-ordinates
mikera
  • 105,238
  • 25
  • 256
  • 415