Skip to content

How can this bot works cross platform?

HungPV edited this page Jan 27, 2023 · 9 revisions

FYI: this bw matrix format is already out of dated. I changed to use another new format tolerant pixel to handle image detection for better result but I'm lazy to write another wiki

This bot use one code but works across platforms like Windows, Linux (and maybe MacOS), here is why:


Original issue:

  • This bot uses pixel color and image detection from screen to make logic
  • Detect pixel color and image from screen usually won't works because the Gamma Correction issue. For example on Linux the green color show as 138,232,67 (RGB) but on Windows it may display as 100,240,50

Resolve:

  • Use a custom format named 'Bw matrix' which was extracted from image with only specified RGB colors are kept
    • Pixels with RGB = 0xFFFFFF (white) are treated as transparent color and any color match this
    • The provided RGB colors must be match within specific tolerant defined in tolerant.color.bw key
    • Other pixels with RGB != 0xFFFFFF and provided RGB will match any pixels with RGB different with provided RGB
  • Basically, the images contain only black and similar to black colors which has minimum change when faced with the Gamma Correction issue and will match cross platforms
  • Use hard-coded coordinate to detect image on a small screen rectangle with good performance and click <= this is why you have to configure screen.offset.x and screen.offset.y on user-config.properties file as described here

For example:

  • Color to keep: 0xFFFFFF (white)
  • Color tolerant = 60 (of the 0xFFFFFF white above)
  • Source image (the Start button when doing fishing): source RGB colors
  • Output: extract matrix result of the Start button when doing fishing
  • The output image has format:
    • color black represents for input color (white in this example)
    • color red represents any color except input color
    • color white represents will match all colors
    • Note: the red color pixels are generated automatically as border of the black area

Sample command:

./matrix.sh FFFFFF 60 /path/to/button/start_fishing.bmp

The matrix app was @Depracated, use the tp app instead

Important: always use BMP images