emiln / cljck

An OS-agnostic Clojure library for automating keyboard and mouse actions.
GNU General Public License v3.0
5 stars 0 forks source link

Ability to assess similarity of images. #11

Closed emiln closed 9 years ago

emiln commented 9 years ago

It would be great to be able to express flows like: If this region of the screen is similar to this old version of it, perform some command. One measure for similarity could be simple color histograms. Here's my thought on a first version:

Similarity is calculated by:

Note that this means you can save a "fingerprint" of an image by saving its bucket values.

emiln commented 9 years ago

The Robot class has a nice method for getting a portion of the screen, which should work well for getting test data. Having a buffered image, you can do something along the lines of:

(let [dummy (int-array 3)]
  (for [x (range (.getWidth img))
        y (range (.getHeight img))]
    (-> img (.getData) (.getPixel x y dummy))))

to get all the pixels, which are really int arrays with three elements: red, green, and blue.