Poker-AI.org
http://poker-ai.org/phpbb/

Screen Scraping
http://poker-ai.org/phpbb/viewtopic.php?f=26&t=2418
Page 1 of 1

Author:  HontoNiBaka [ Wed Mar 20, 2013 1:48 am ]
Post subject:  Screen Scraping

I had a programm, that calculated equities live at the table, also EVs and some other stuff. I was using the live handhistories generated by FreePHG, but it doesnt work anymore. Does anyone know any way to get the table informations from Party, that is compatible with java code? If there does not exist such a framework, I am willing to port my code to c++.

Author:  proud2bBot [ Wed Mar 20, 2013 3:23 am ]
Post subject:  Re: Screen Scrapping

Scraping can be applied on all clients, even though it works best in a fixed setting, like simple scheme, fixed table size etc. There are some frameworks available (you might look into the archive of the old forum). Personally, I programmed an own OCR, which needs to learn all letters (can be made very easy; I take a screenshot from tables over x minutes - ideally rush because of changing players) and extract each unknown character, which will be written in an own file. Then you just need to name the files according to the character and they can be used by the OCR. The plus point of this technique is a recognition rate of 100%, the minus is you need to adapt it if the client fonts changes.

Author:  HontoNiBaka [ Wed Mar 20, 2013 4:02 am ]
Post subject:  Re: Screen Scrapping

Thx for the reply. I have read a little in the archives, OCR seems to be the way to go.

Ive a few open scraping programs, they dont seem to work that well so far. I will probably implement it myself too. I know there is something in the openholdem forum, maybe I should check it out, but I wonder if its easy to detect.

Ive read, that most people only do the scraping, if its their turn, but you will probably still need the screenshot every few ms, so you at least can check if the buttons are there, I wonder if there is a faster way to know, when to scrap.

Author:  proud2bBot [ Wed Mar 20, 2013 4:25 am ]
Post subject:  Re: Screen Scrapping

That's site dependent. For Party, the buttons were standard Windows Widget, so you could just query if the fold button is visible and then take a screenshot. If no such shortcut is possible and your window is fixed and visible, you can try to ask for a pixel color on a point where the fold button should be instead of taking a whole screenshot.

Author:  HontoNiBaka [ Mon Apr 01, 2013 4:12 am ]
Post subject:  Re: Screen Scrapping

I have now implemented my scraper. After reading a lot on this forum and in the archives I also know, that the type of program I wrote is called an advisor. So yea, my advisor is working again, thx for the help.

Author:  HontoNiBaka [ Wed Apr 03, 2013 4:54 am ]
Post subject:  Re: Screen Scrapping

I have created 2 little benchmarks:

Code:
public class Main {

   /**
    * @param args
    */
   public static void main(String[] args) {
      Robot r;
      try {
         for(int i = 0; i < 1000000; i++){
            int b = i*i;
            System.out.println(i);
         }
         r = new Robot();
         System.out.println("Start");
         long startTime = System.currentTimeMillis();
         for(int i = 0; i < 1000; i++){
            Color c = r.getPixelColor(100, 100);
         }
         System.out.println("Time: " + (System.currentTimeMillis() - startTime)*0.001 + "ms per iteration");
      } catch (AWTException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }
   }
}


Time: 22.141000000000002ms per iteration


Code:
public class Main {

   /**
    * @param args
    */
   public static void main(String[] args) {
      Robot r;
      try {
         for(int i = 0; i < 1000000; i++){
            int b = i*i;
            System.out.println(i);
         }
         r = new Robot();
         System.out.println("Start");
         long startTime = System.currentTimeMillis();
         for(int i = 0; i < 1000; i++){
            BufferedImage image = r.createScreenCapture(new Rectangle(600, 400));
            image.getSubimage(0,0,20,20);
            image.getSubimage(0,0,20,20);
            image.getSubimage(0,0,20,20);
         }
         System.out.println("Time with Subimage: " + (System.currentTimeMillis() - startTime)*0.001 + "ms per iteration");
         startTime = System.currentTimeMillis();
         for(int i = 0; i < 1000; i++){
            r.createScreenCapture(new Rectangle(20, 20));
            r.createScreenCapture(new Rectangle(20, 20));
            r.createScreenCapture(new Rectangle(20, 20));
         }
         System.out.println("Time without Subimage: " + (System.currentTimeMillis() - startTime)*0.001  + "ms per iteration");
      } catch (AWTException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }
   }

Time with Subimage: 21.661ms per iteration
Time without Subimage: 87.92ms per iteration


The results are a little strange, but I think we can see, that its better to take a bigger screenshot in java and to process that image, instead of taking many small screenshots as many do.

Checking for changed pixels with getPixelColor() Also has no benefits over just taking a screenshot.

Author:  HontoNiBaka [ Wed Apr 03, 2013 7:44 pm ]
Post subject:  Re: Screen Scraping

I tested it again, it turns out I had aero designs enabled.

Time with Subimage: 0.429ms per iteration
Time without Subimage: 0.227ms per iteration

Turns out without aero taking screenshots is way faster and smaller screenshots are faster than cropping images out of a single bigger screenshot. Definitelly something to check if your scraper is slow.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/