anti-prestige-tool/README.md
2026-05-01 10:26:41 +01:00

202 lines
4.6 KiB
Markdown

# Anti Prestige Tool
Prototype queue-position reader for Arma Reforger.
## Current State
The working script is:
```bash
python3 reforger_queue_read.py
```
It reads the queue number by:
1. Cropping the queue-number region.
2. Thresholding orange UI pixels.
3. Splitting connected digit components.
4. Matching digits against synthetic `Roboto-Condensed` templates.
No Tesseract/OpenCV/Pillow dependency is currently required.
## Dataset Validation
Dataset:
```text
/home/scootz/Pictures/codex-dataset
```
Validation command:
```bash
python3 reforger_queue_read.py --dataset /home/scootz/Pictures/codex-dataset --expect-filenames
```
Current result:
```text
summary: 14 passed, 0 failed
```
The default crop is derived from this 2560x1440 reference:
```text
reference-size: 2560x1440
reference-crop: x=1050 y=620 width=100 height=60
scale-mode: width
```
`scale-mode=width` means the crop scales uniformly from the screenshot width. This handles the current dataset better than independent width/height scaling because the dataset images are slightly shorter than 1440 pixels, while the UI coordinates still match a 1440p layout.
## Real Screenshot Calibration
Dataset:
```text
datasets/scootz-dataset
```
Files:
```text
1920x1080.png
2160x1440.png # actual image size is 2560x1440
```
Validation command:
```bash
python3 reforger_queue_read.py --dataset datasets/scootz-dataset --show-crop --debug
```
Current result:
```text
datasets/scootz-dataset/1920x1080.png crop=788,465,75,45
datasets/scootz-dataset/1920x1080.png 22
datasets/scootz-dataset/2160x1440.png crop=1050,620,100,60
datasets/scootz-dataset/2160x1440.png 24
```
Measured digit box positions:
```text
1440p digit bbox abs=(1080,636)-(1118,666)
1440p digit bbox rel=(0.421875,0.441667)-(0.436719,0.462500)
1080p digit bbox abs=(810,477)-(838,500)
1080p digit bbox rel=(0.421875,0.441667)-(0.436458,0.462963)
```
The match is exact enough to use width-scaled coordinates for normal 16:9 1080p and 1440p users.
Default search crop relative to a 2560x1440 screen:
```text
x=1050 / 2560 = 0.410156
y=620 / 1440 = 0.430556
w=100 / 2560 = 0.039063
h=60 / 1440 = 0.041667
```
Resolved default crop examples:
```text
2560x1440 -> x=1050 y=620 width=100 height=60
1920x1080 -> x=788 y=465 width=75 height=45
```
## Single-Monitor Capture Direction
The old approach captured the whole KDE desktop across all screens. That is not ideal.
List available KWin outputs:
```bash
python3 reforger_queue_read.py --list-screens
```
Example output:
```text
DP-2 enabled 0,360,1920x1080
DP-3 enabled 1920,0,2560x1440
```
Preferred live usage is to pass the screen containing Reforger explicitly:
```bash
python3 reforger_queue_read.py --capture --screen DP-3 --show-crop --debug
```
The tool first tries KWin's screen-specific screenshot API. On this machine KWin currently rejects that direct API for an untrusted process, so the tool falls back to:
1. Capturing the full Spectacle desktop.
2. Cropping to the requested KWin output geometry.
3. Applying the queue-number crop inside that monitor image.
This still avoids the "wrong current monitor" problem. It does not yet avoid the temporary full-desktop screenshot in the fallback path.
The script also supports Spectacle's current-monitor capture:
```bash
python3 reforger_queue_read.py --capture
```
This uses:
```bash
spectacle --background --current --nonotify --output <tempfile>
```
That should capture only one monitor. For this to work reliably, Reforger should be focused or the relevant monitor should be the current KDE monitor.
Whole-desktop capture is still available for fallback:
```bash
python3 reforger_queue_read.py --capture --capture-mode fullscreen
```
Live DP-3 test result from 2026-05-01:
```text
crop=1050,620,100,60
19
```
## Useful Commands
Read a full single-monitor screenshot:
```bash
python3 reforger_queue_read.py --image /path/to/screenshot.png --debug
```
Show the crop selected for a screenshot:
```bash
python3 reforger_queue_read.py --image /path/to/screenshot.png --show-crop --debug
```
Read a full screenshot with an explicit crop:
```bash
python3 reforger_queue_read.py --image /path/to/screenshot.png --crop 1050,620,100,60 --debug
```
Read already-cropped number images:
```bash
python3 reforger_queue_read.py --dataset /path/to/cropped-digits --cropped --expect-filenames
```
## Next Step
Get real full screenshots from the game on the actual monitor setup and validate:
```bash
python3 reforger_queue_read.py --image /path/to/real-full-screenshot.png --debug
```
If the default crop misses, use ImageMagick to crop around the queue value, then update `--reference-crop`.