Poker-AI.org

Poker AI and Botting Discussion Forum
It is currently Mon Nov 13, 2023 6:51 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Screen Scraping
PostPosted: Wed Mar 20, 2013 1:48 am 
Offline
Veteran Member

Joined: Wed Mar 20, 2013 1:43 am
Posts: 267
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++.


Last edited by HontoNiBaka on Wed Apr 03, 2013 4:55 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Screen Scrapping
PostPosted: Wed Mar 20, 2013 3:23 am 
Offline
Senior Member

Joined: Mon Mar 11, 2013 10:24 pm
Posts: 216
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.


Top
 Profile  
 
 Post subject: Re: Screen Scrapping
PostPosted: Wed Mar 20, 2013 4:02 am 
Offline
Veteran Member

Joined: Wed Mar 20, 2013 1:43 am
Posts: 267
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.


Top
 Profile  
 
 Post subject: Re: Screen Scrapping
PostPosted: Wed Mar 20, 2013 4:25 am 
Offline
Senior Member

Joined: Mon Mar 11, 2013 10:24 pm
Posts: 216
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.


Top
 Profile  
 
 Post subject: Re: Screen Scrapping
PostPosted: Mon Apr 01, 2013 4:12 am 
Offline
Veteran Member

Joined: Wed Mar 20, 2013 1:43 am
Posts: 267
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.


Top
 Profile  
 
 Post subject: Re: Screen Scrapping
PostPosted: Wed Apr 03, 2013 4:54 am 
Offline
Veteran Member

Joined: Wed Mar 20, 2013 1:43 am
Posts: 267
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.


Top
 Profile  
 
 Post subject: Re: Screen Scraping
PostPosted: Wed Apr 03, 2013 7:44 pm 
Offline
Veteran Member

Joined: Wed Mar 20, 2013 1:43 am
Posts: 267
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group