Skip to content
This repository has been archived by the owner on May 1, 2022. It is now read-only.

carmelosantana/rok-monster-ocr

Repository files navigation

Rise of Kingdoms OCR Tools

🌞 It brings me great pleasure to announce the golang fork by xor22h will be the official supported OCR client of the RoK Monster community. You can expect a vastly improved experience on nearly all existing RoK Monster features while greatly increasing usability.

πŸ₯° Thank you everyone for all the help and suggestions as we put the php version of RoK Monster to rest. I look forward to our community's next chapter.

πŸ‘‹ Join our Discord for help getting started or show off your results!


Archives

Repository Description
rok-monster-ai Unfinished automated kingdom assistant. Used php-adb to perform scripted events on an Android device.
rok-monster-ocr This repository.
rok-monster-samples Sample images sorted by resolution and client version
rok-monster-schema Instruction sets to standardize OCR processes.
rok-monster-ui WordPress theme originally on rokmonster.com providing a web UI for rok-monster-ocr CLI.

Discord License: MIT


Kingdom Statistics

Command line tools to help collect player statistics from Rise of Kingdoms. By analyzing screenshots we can extract various data points such as governor power, deaths, kills and more. This can help with various kingdom statistics or fairly distributing KvK rewards.

Sample

Results may vary.

Features

  • Character recognition by Tesseract
  • Fast hash based image comparison
  • Live results with adb

Limitations

  • Best results with a 16:9 image at 1920*1080.
  • English language is preferred as coordinate information lines up most accurately with English.

Process

Below is a quick overview of the actions performed while executing the job governor-more-info-kills.

  1. rok-monster-ocr will iterate through each screenshot and compare the input image to a known fingerprint of the image containing data to capture.
  2. If a match is made the image is prepared per the instructions declared in the OCR profile. Each cropped segment represents a single data point.
    • This process is repeated for each image in the input_path.
  3. By default on completion a table is printed via CLI and a CSV file is saved in the current working directory.

πŸ“Œ Input path can be defined in .env file or via CLI argument --input_path.

Install

Official Support

  • Ubuntu 20.04.2

Automated

One line install.

curl -sSL https://raw.githubusercontent.com/carmelosantana/rok-monster-ocr/master/install.sh | bash -s y

This will install all necessary dependencies and start a small demo project.


Alternatively you can clone the repository and review the install script before executing.

git clone https://github.com/carmelosantana/rok-monster-ocr/
cd rok-monster-ocr
sudo bash install.sh

Manual

Requirements:

Software

This assumes you already have PHP installed with access to Composer.

sudo apt install imagemagick ffmpeg tesseract-ocr

This does not represent the complete install instructions for all dependencies. Please review the install script for detailed installation instructions.

Tessdata

Using tessdata or tessdata_best models from the Tesseract repositories have produced better results than the models provided by apt-get. You can download select languages or clone the repository and set this path with in the .env file or via CLI argument --tessdata.

Alternatively you can install via apt-get. Some issues may include:

  • Incorrect user permissions
  • Models don't work with legacy engine
  • Can be less accurate
sudo apt install tesseract-ocr-all

rok-monster-ocr

git clone https://github.com/carmelosantana/rok-monster-ocr
cd rok-monster-ocr
composer install

Community Installs

These install methods are contributions made available by the community with no official support. It's the contributor's discretion to offer support via Discord.

Method Author README
Docker xor22h docker.md

Usage

Start a job via CLI

  1. Capture the necessary screens specified per the given job. In this example we need the Governor More Info profile screen.

  2. Move all images to your "Input Path" as defined in your .env file or via CLI argument --input_path.

    By default a "Media" folder is created in your current working directory if no directory is supplied.

  3. Run job:

    php rok.php --job=governor-more-info-kills --input_path=DIR_WITH_SCREENSHOTS
    Value Description
    governor-more-info-kills Default job for collecting kill points.
    DIR_WITH_SCREENSHOTS Full or relative path to DIR with screen shots.
  4. Check your current working directory for any output files.

Arguments

Argument Value Default Description
debug bool 0 Prints raw OCR reading per image. Uses local --tmp_path and preserves cropped images.
job string Required Name of job defined as defined in rok-monster-schema
input_path string Required Media source path or file
output_path string getcwd() Output path for csv.
tmp_path string sys_get_temp_dir() Temp directory for images manipulated during processing
oem int 0 OCR Engine Mode
psm int 0 Page Segmentation Method
tessdata string null User defined location for tessdata. Defaults to system installation path.
compare_to_sample bool 1 Enable compare to sample
video bool 1 Enable video processing
  • bool as 0\1 or true\false or on\off

Community

Have a question, an idea, or need help getting started? Checkout our Discord!

Honorable mentions for community members who've donated time and resources to rok-monster-ocr or rokmonster.com.

  • BouchB
  • j7johnny
  • Star Lordツ

Funding

If you find this project useful or use it in a commercial environment to manage your kingdom please consider donating today with one of the following options.

  • PayPal
  • Bitcoin bc1qx7v5vvxwnhpl3dssggy0hytcx2rpq5dkkfwyy4
  • Ethereum 0xA8Ebb6e5EC503E90551dD1bdE2d00B6C126eD5C5
  • Tron TPnGEfkUZ2py6CFkh8wgqqYehJ29EbMWVw

License

The code is licensed MIT and the documentation is licensed CC BY-SA 4.0.