Results 1 to 1 of 1
  1. #1
    Member
    Luriebot is offline

    Posts
    85

    Group Assistance

    So i have the following methods for finding images:
    Code:
        public static Point findImage(BufferedImage bmpNeedle, BufferedImage bmpHaystack) {
            Point p = null;
            Point zero = new Point(0, 0);
            Color haystackColor = new Color(bmpHaystack.getRGB(0, 0));
            Color needleColor = new Color(bmpNeedle.getRGB(0, 0));
            for (int i = 0; i < (bmpHaystack.getWidth() - bmpNeedle.getWidth()); i++) {
                for (int j = 0; j < (bmpHaystack.getHeight() - bmpNeedle.getHeight()); j++) {
                    haystackColor = new Color(bmpHaystack.getRGB(i, j));
                    needleColor = new Color(bmpNeedle.getRGB(0, 0));
                    if ((haystackColor.equals(needleColor))) {
                        p = check(bmpNeedle, bmpHaystack, needleColor, haystackColor, i, j);
                        if (!p.equals(zero)) {
                            return p;
                        }
                    }
                }
            }
            return new Point(0, 0);
        }
    and for counting occurrence i have
    Code:
        public static int countOccurance(BufferedImage bmpNeedle, BufferedImage bmpHaystack) {
            int occurance = 0;
            Point p = null;
            Point zero = new Point(0, 0);
            Color haystackColor = new Color(bmpHaystack.getRGB(0, 0));
            Color needleColor = new Color(bmpNeedle.getRGB(0, 0));
            for (int i = 0; i < (bmpHaystack.getWidth() - bmpNeedle.getWidth()); i++) {
                for (int j = 0; j < (bmpHaystack.getHeight() - bmpNeedle.getHeight()); j++) {
                    haystackColor = new Color(bmpHaystack.getRGB(i, j));
                    needleColor = new Color(bmpNeedle.getRGB(0, 0));
                    if ((haystackColor.equals(needleColor))) {
                        p = check(bmpNeedle, bmpHaystack, needleColor, haystackColor, i, j);
                        if (!p.equals(zero)) {
                            occurance++;
                        }
                    }
                }
            }
            return occurance;
        }
    These are the problems with the above methods:
    Slow
    Specific
    Eat CPU

    I have a few solutions that i am trying and they are:
    Limit the search space to the smallest possible area so that less pixels are run through the above.
    Build a remember function that will search pixels around the area the image was found earlier to find moving images.
    Remember patterns not specific pixel data so that images with slightly altered rbg values still get found.

    The problems I am having are as follows:
    Regardless of what i have done i am still having problems speeding up the detection time.
    CPU is still being eaten alive which as i have been lead to understand causes detection.

    If you have any ideas or thoughts on how to speed up the image finding process in JAVA specifically please leave a post. I understand that and have been told many times that java is not a language for bots however i have used java and programmed with it many times and know that it can be so please don't leave a lecture on how one language is better then another. Thanks in advance guys!
    Last edited by Luriebot; 08-29-2013 at 04:14 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •