简体   繁体   中英

Java BufferedImage = Robot.createScreenCapture() not fast enought

I'm trying to make bot which will play facebook messenger basketball or football for me (cause I'm really bad at it). I even made something few years ago, but there was problems in both games. In basketball when basket started to move so fast that my program was making mistakes in calculations and in soccer when ball was moving to fast. I was using Robot.createScreenCapture() of the fragment of screen and then saved it in BufferedImage and I was checking every pixel in image, but it's not fast enought (I tried with Piano Tiles 2 too). I need something which is way more fast.

You do not provide details about how you locate the ball in BufferedImage object.

You could:

  • Improve the location process effectiveness by so called logarithmic search.
  • Reduce the search area by using motion prediction techniques.

If you have not tried any of these two (you mentioned '...every pixel...'), I would start with the first one: Find approximate location of the ball by scanning pixels in a rough grid and then refine the location in the reduced search area around the approximate location.

To use rough grid I mean to scan every n-th row and column, where n will be the ball radius or more precisely sqrt(2*r*r)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM