Topic
2 replies Latest Post - ‏2013-09-12T05:37:11Z by ChrisGF
ChrisGF
ChrisGF
158 Posts
ACCEPTED ANSWER

Pinned topic Blinking Image Recognition

‏2013-09-11T06:10:25Z |

Hello,

is there a way to check if a particular object is blinking?

I have an indicator in my application and would like to check if its blinking while the program loads the results.

Thank you for your attention,

Krisz

  • Y5QY_gerben_delange
    Y5QY_gerben_delange
    34 Posts
    ACCEPTED ANSWER

    Re: Blinking Image Recognition

    ‏2013-09-11T14:08:10Z  in response to ChrisGF

    Hi,

    First off, you could check if some object property changes when color changes. Here's some code:

     

     

          public voidtestMain(Object[] args) {

     

                booleanpropertiesChange = false;

                String properties = "";

     

                for(inti = 0; i < 200; i++) {

                      // change recognition properties accordingly

                   

      TestObject[] thingy = getRootTestObject().find(

                                 atDescendant(".class", "someClass", "someProperty",

                                              "someValue"));

                      if((thingy != null) && (thingy.length> 0)) {

                            if(i == 0) {

                                 // write properties to propertie string first time in loop

                                 properties = thingy[0].getProperties().toString();

                     

                                 // compare propertie set

                            } else if(!thingy[0].getProperties().toString().equals(properties)) {

                                 System.out.println("Properties changed!");

                                 System.out.println("Property set 1: "+ properties);

                                 System.out.println("Property set 2: "

                                             + thingy[0].getProperties().toString());

                                 propertiesChange = true;

                                 break;

                            }else{

                                 System.out.println("no change");

                            }

     

                      } else{

                            System.out.println("Object not found");

                            break;

                      }

     

                      sleep(0.5);

                }

     

                // report something

                if(propertiesChange) {

     

                } else{

     

                }

     

                unregisterAll();

     

          }

    }

     

     ------------------------

    If that doesn't work you can try taking a couple of screenshots, and compare the images bit by bit:

     

    boolean bufferedImagesEqual(BufferedImage img1, BufferedImage img2) {

      if (img1.getWidth() == img2.getWidth() && img1.getHeight() == img2.getHeight() ) {

        for (int x = 0; x < img1.getWidth(); x++) {

          for (int y = 0; y < img1.getHeight(); y++) {

            if (img1.getRGB(x, y) != img2.getRGB(x, y) ) return false;

          }

        }

      else {

        return false;

      }

      return true;

    }

     

     

    good luck,

     

    g


     edit:

    Updated on 2013-09-11T14:36:28Z at 2013-09-11T14:36:28Z by Y5QY_gerben_delange
    • ChrisGF
      ChrisGF
      158 Posts
      ACCEPTED ANSWER

      Re: Blinking Image Recognition

      ‏2013-09-12T05:37:11Z  in response to Y5QY_gerben_delange

      Wow Gerben! Such wonderful answer!

      Thank you for your help and for the codes too!

      Have a nice day!

      Krisz