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 9 of 9

Thread: I'm making a program that recognizes cards say for poker

  1. #1
    Member
    Join Date
    Jan 2012
    Posts
    67
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default I'm making a program that recognizes cards say for poker

    this is the code i have so far:

    <
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.Robot;
    import java.awt.AWTException;
    import java.awt.Rectangle;
    import java.awt.Color;
    import java.awt.Toolkit;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    import java.awt.Point;
    import java.lang.Object;
    import java.awt.geom.Point2D;
    import java.until.Arrays:
     
    public class Poker
    {
     
      public int main(String[] args) throws Exception
      {
    	Robot robot = new Robot();
    	Color color1 = new Color(24, 26, 25);
    	int[] Array;
    	Array = new int[5];
    	Array[0] = (new Color(24, 26, 25)).getRGB();
    	Array[1] = (new Color(28, 40, 36)).getRGB();
    	Array[2] = (new Color(93, 89, 79)).getRGB();
    	Array[3] = (new Color(49, 51, 46)).getRGB();
    	Array[4] = (new Color(17, 30, 25)).getRGB();
     
    	Rectangle rectangle = new Rectangle(0, 0, 1365, 770);
     
    	BufferedImage image = robot.createScreenCapture(rectangle);
    		for(int x = 0; x < rectangle.getWidth(); x++) 
    		{
    			for (int y = 0; y < rectangle.getHeight(); y++) 
    			{
    				int[] pixels = image.getRGB(0, 0, image.getWidth(), image.getHeight(), null, 0, image.getWidth()); 
    				{
    					for (int i = 0; i < pixels.length; i++) 
    					{
    						if (Array.equals(search, Array.copyOfRange(pixels, i, i + search.length))) 
    							{
    								if(image.getRGB(x, y) == color1.getRGB())
    								{
    									robot.mouseMove(x, y);
    									robot.mousePress(InputEvent.BUTTON1_MASK);
    									robot.delay(10);
    									robot.mouseRelease(InputEvent.BUTTON1_MASK);
    								}
    							}
     
    						break;
    						}
    					}
    				}
    			}
    		}
    	}
    >

    i am getting 4 errors

    1 java:42 cannot find symbol pointing at the search

    2 java:42 cannot find symbol pointing at the search

    3 java:42 operator + cannot be applied to int,search.length

    4 java:42 cannot find symbol pointing at the Array.copyOfRange

    now what this program is supposed to do:

    take a screenshot buffer it and search through it until it finds 5 pixels with the same RGB values as in the Array and then using that same screenshot find the first pixel and move the mouse to it.

    PS. sorry bout the weird looking deal im coding in NotePad++ and i guess those lines that are wrapped around are too long for the post sorry again
    Last edited by Lurie1; February 13th, 2012 at 12:36 AM.


  2. #2
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: I'm making a program that recognizes cards say for poker

    Paste the exact error messages here. And try to understand the error messages, you will be able to solve them on their own.

  3. #3
    Member
    Join Date
    Jan 2012
    Posts
    67
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: I'm making a program that recognizes cards say for poker

    the reason im posting is because i dont know how to solve them and i understand them but because i imported the whatchumacallit and all idk why im getting them

    1. java:43 cannot find symbol
    symbol : variable search
    location: class Poker

    if (Array.equals(search, Array.copyOfRange(pixels, i , i + search.length)))
    ^

    2: same error pointing at the second search
    ^

    3: operatior + cannot be applied to int,search. length
    copyOfRange(pixels, i , i + search.length)))
    ^

    4: cannot find symbol
    symbol : method copyOfRange(int[].int,<nulltype>)
    location: class int[]
    if (Array.equals(search, Array.copyOfRang(pixels, i, i + search.length)))
    ^
    Last edited by Lurie1; February 13th, 2012 at 01:12 AM.

  4. #4
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: I'm making a program that recognizes cards say for poker

    if (Array.equals(search, Array.copyOfRange(pixels, i, i + search.length)))
    What is search?

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: I'm making a program that recognizes cards say for poker

    Why are you using static methods of the Array class? Does it have the methods you are calling?

  6. #6
    Member
    Join Date
    Jan 2012
    Posts
    67
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: I'm making a program that recognizes cards say for poker

    no i guess it does not but i imported the untility.Arrays so i was under the impression i could use search and other tools without making methods around them?

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: I'm making a program that recognizes cards say for poker

    Array is not Arrays. Your code uses the Array class???

  8. #8
    Member
    Join Date
    Jan 2012
    Posts
    67
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: I'm making a program that recognizes cards say for poker

    yes it does

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: I'm making a program that recognizes cards say for poker

    Does it work the way you want it to?

Similar Threads

  1. So I'm making this program...
    By SkyAphid in forum The Cafe
    Replies: 2
    Last Post: August 29th, 2011, 05:55 PM
  2. Adding cards back into deck
    By sp4ce in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 15th, 2011, 01:21 AM
  3. Very basic program but its making me crazy
    By craig carl in forum What's Wrong With My Code?
    Replies: 5
    Last Post: February 2nd, 2011, 03:16 PM
  4. Sorting a deck of cards by suite or rank.
    By coyne20 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 13th, 2010, 08:47 AM
  5. Need help making program
    By ixjaybeexi in forum Collections and Generics
    Replies: 5
    Last Post: December 6th, 2009, 11:36 PM