Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Identifying something on screen.

  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Identifying something on screen.

    I want to be able to return the coordinates of small image on my screen, how can I go about sensing its location and returning those coordinates? For example if I wanted to make the Robot class click on this no matter where I move it on the screen.


  2. #2
    Member angstrem's Avatar
    Join Date
    Mar 2013
    Location
    Ukraine
    Posts
    200
    My Mood
    Happy
    Thanks
    9
    Thanked 31 Times in 29 Posts

    Default Re: Identifying something on screen.

    I would use the following algorithm:

    0. Convert a sample image in a BufferedImage - just so you can compare.
    1. For each pixel on the screen:
    1.1. Create screenshot of a rectangular part of a screen with the upper left corner in this pixel and dimensions equal to your target image ones. You can do that with Robot.createScreenCapture.
    1.2. Use BufferedImage.getRGB to get array of RGB data
    1.3. Use similar function on your sample image from (0)
    1.4. Compare (1.2.) and (1.3.) to first (bunch) of failures. If failed (n times) - go to the next pixel, if not - return the coordinates.

    Or, for instance, you can use some neural network libs for image recognition.

Similar Threads

  1. Identifying OO elements in this scenario
    By vinayjava in forum Object Oriented Programming
    Replies: 6
    Last Post: December 26th, 2012, 04:00 AM
  2. Replies: 9
    Last Post: December 31st, 2011, 01:22 AM
  3. recursion for identifying amount of zeroes in minesweeper demo
    By Nightingale in forum Algorithms & Recursion
    Replies: 1
    Last Post: November 28th, 2011, 03:33 PM
  4. Identifying invalid calls
    By joshft91 in forum Object Oriented Programming
    Replies: 1
    Last Post: February 26th, 2011, 05:38 PM
  5. Identifying calling object
    By frogfury in forum What's Wrong With My Code?
    Replies: 6
    Last Post: October 25th, 2010, 05:13 PM