interpreter-v2 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- interpreter_v2-0.1.0/.claude/settings.local.json +27 -0
- interpreter_v2-0.1.0/.gitignore +28 -0
- interpreter_v2-0.1.0/.python-version +1 -0
- interpreter_v2-0.1.0/PKG-INFO +149 -0
- interpreter_v2-0.1.0/README.md +122 -0
- interpreter_v2-0.1.0/benchmark/README.md +106 -0
- interpreter_v2-0.1.0/benchmark/data/001_miguel_pendant/content.png +0 -0
- interpreter_v2-0.1.0/benchmark/data/001_miguel_pendant/ground_truth.txt +1 -0
- interpreter_v2-0.1.0/benchmark/data/001_miguel_pendant/ground_truth_translation.txt +2 -0
- interpreter_v2-0.1.0/benchmark/data/002_cress_pendant/content.png +0 -0
- interpreter_v2-0.1.0/benchmark/data/002_cress_pendant/ground_truth.txt +1 -0
- interpreter_v2-0.1.0/benchmark/data/002_cress_pendant/ground_truth_translation.txt +3 -0
- interpreter_v2-0.1.0/benchmark/data/003_screen3/content.png +0 -0
- interpreter_v2-0.1.0/benchmark/data/003_screen3/ground_truth.txt +1 -0
- interpreter_v2-0.1.0/benchmark/data/003_screen3/ground_truth_translation.txt +4 -0
- interpreter_v2-0.1.0/benchmark/data/004_screen4/content.png +0 -0
- interpreter_v2-0.1.0/benchmark/data/004_screen4/ground_truth.txt +1 -0
- interpreter_v2-0.1.0/benchmark/data/004_screen4/ground_truth_translation.txt +4 -0
- interpreter_v2-0.1.0/benchmark/data/005_screen5/content.png +0 -0
- interpreter_v2-0.1.0/benchmark/data/005_screen5/ground_truth.txt +1 -0
- interpreter_v2-0.1.0/benchmark/data/005_screen5/ground_truth_translation.txt +3 -0
- interpreter_v2-0.1.0/benchmark/data/006_screen6/content.png +0 -0
- interpreter_v2-0.1.0/benchmark/data/006_screen6/ground_truth.txt +1 -0
- interpreter_v2-0.1.0/benchmark/data/006_screen6/ground_truth_translation.txt +3 -0
- interpreter_v2-0.1.0/benchmark/data/007_screen7/content.png +0 -0
- interpreter_v2-0.1.0/benchmark/data/007_screen7/ground_truth.txt +1 -0
- interpreter_v2-0.1.0/benchmark/data/007_screen7/ground_truth_translation.txt +3 -0
- interpreter_v2-0.1.0/benchmark/data/008_screen8/content.png +0 -0
- interpreter_v2-0.1.0/benchmark/data/008_screen8/ground_truth.txt +1 -0
- interpreter_v2-0.1.0/benchmark/data/008_screen8/ground_truth_translation.txt +3 -0
- interpreter_v2-0.1.0/benchmark/data/009_screen9/content.png +0 -0
- interpreter_v2-0.1.0/benchmark/data/009_screen9/ground_truth.txt +1 -0
- interpreter_v2-0.1.0/benchmark/data/009_screen9/ground_truth_translation.txt +3 -0
- interpreter_v2-0.1.0/benchmark/data/010_screen10/content.png +0 -0
- interpreter_v2-0.1.0/benchmark/data/010_screen10/ground_truth.txt +1 -0
- interpreter_v2-0.1.0/benchmark/data/010_screen10/ground_truth_translation.txt +3 -0
- interpreter_v2-0.1.0/benchmark/data/011_screen11/content.png +0 -0
- interpreter_v2-0.1.0/benchmark/data/011_screen11/ground_truth.txt +1 -0
- interpreter_v2-0.1.0/benchmark/data/011_screen11/ground_truth_translation.txt +3 -0
- interpreter_v2-0.1.0/benchmark/data/012_screen12/content.png +0 -0
- interpreter_v2-0.1.0/benchmark/data/012_screen12/ground_truth.txt +1 -0
- interpreter_v2-0.1.0/benchmark/data/012_screen12/ground_truth_translation.txt +3 -0
- interpreter_v2-0.1.0/benchmark/data/013_screen13/content.png +0 -0
- interpreter_v2-0.1.0/benchmark/data/013_screen13/ground_truth.txt +1 -0
- interpreter_v2-0.1.0/benchmark/data/013_screen13/ground_truth_translation.txt +3 -0
- interpreter_v2-0.1.0/benchmark/results/2025-12-29_00-09-04.json +180 -0
- interpreter_v2-0.1.0/benchmark/results/2025-12-29_00-30-57.json +31 -0
- interpreter_v2-0.1.0/benchmark/results/2025-12-29_00-35-48.json +180 -0
- interpreter_v2-0.1.0/benchmark/results/2025-12-29_00-35-48_with_translation.json +181 -0
- interpreter_v2-0.1.0/benchmark/results/2025-12-29_00-47-32.json +261 -0
- interpreter_v2-0.1.0/benchmark/results/2025-12-29_00-51-43.json +352 -0
- interpreter_v2-0.1.0/benchmark/results/2025-12-29_00-54-04.json +352 -0
- interpreter_v2-0.1.0/benchmark/results/2025-12-29_00-57-41.json +463 -0
- interpreter_v2-0.1.0/benchmark/results/2025-12-29_00-58-22.json +463 -0
- interpreter_v2-0.1.0/benchmark/results/2025-12-29_01-01-10.json +574 -0
- interpreter_v2-0.1.0/benchmark/results/2025-12-29_01-03-27.json +685 -0
- interpreter_v2-0.1.0/benchmark/results/2025-12-29_01-05-31.json +796 -0
- interpreter_v2-0.1.0/benchmark/results/2025-12-29_01-07-51.json +907 -0
- interpreter_v2-0.1.0/benchmark/results/2025-12-29_01-13-17.json +1018 -0
- interpreter_v2-0.1.0/benchmark/run_benchmark.py +594 -0
- interpreter_v2-0.1.0/config.yml +19 -0
- interpreter_v2-0.1.0/current_capture.png +0 -0
- interpreter_v2-0.1.0/debug_capture.png +0 -0
- interpreter_v2-0.1.0/install.ps1 +45 -0
- interpreter_v2-0.1.0/pyproject.toml +52 -0
- interpreter_v2-0.1.0/sample.jpg +0 -0
- interpreter_v2-0.1.0/src/interpreter/__init__.py +13 -0
- interpreter_v2-0.1.0/src/interpreter/__main__.py +450 -0
- interpreter_v2-0.1.0/src/interpreter/capture.py +155 -0
- interpreter_v2-0.1.0/src/interpreter/capture_macos.py +295 -0
- interpreter_v2-0.1.0/src/interpreter/capture_windows.py +366 -0
- interpreter_v2-0.1.0/src/interpreter/config.py +72 -0
- interpreter_v2-0.1.0/src/interpreter/gpu.py +62 -0
- interpreter_v2-0.1.0/src/interpreter/models.py +39 -0
- interpreter_v2-0.1.0/src/interpreter/ocr.py +453 -0
- interpreter_v2-0.1.0/src/interpreter/overlay.py +483 -0
- interpreter_v2-0.1.0/src/interpreter/translate.py +169 -0
- interpreter_v2-0.1.0/test_builtin.png +0 -0
- interpreter_v2-0.1.0/test_capture.py +45 -0
- interpreter_v2-0.1.0/test_capture2.py +62 -0
- interpreter_v2-0.1.0/test_capture3.py +43 -0
- interpreter_v2-0.1.0/test_capture4.py +56 -0
- interpreter_v2-0.1.0/test_crop.py +54 -0
- interpreter_v2-0.1.0/test_cropped.png +0 -0
- interpreter_v2-0.1.0/test_frame.png +0 -0
- interpreter_v2-0.1.0/test_free_threaded.png +0 -0
- interpreter_v2-0.1.0/test_free_threaded.py +67 -0
- interpreter_v2-0.1.0/test_manual.png +0 -0
- interpreter_v2-0.1.0/test_methods.py +19 -0
- interpreter_v2-0.1.0/test_original.png +0 -0
- interpreter_v2-0.1.0/test_threaded.py +68 -0
- interpreter_v2-0.1.0/uv.lock +1048 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(python -m interpreter:*)",
|
|
5
|
+
"Bash(where.exe:*)",
|
|
6
|
+
"Bash(/c/Users/bertr/.local/bin/uv sync)",
|
|
7
|
+
"Bash(/c/Users/bertr/.local/bin/uv run:*)",
|
|
8
|
+
"Bash(PYTHONIOENCODING=utf-8 /c/Users/bertr/.local/bin/uv run:*)",
|
|
9
|
+
"Bash(tasklist:*)",
|
|
10
|
+
"Bash(taskkill:*)",
|
|
11
|
+
"Bash(git ls-tree:*)",
|
|
12
|
+
"WebFetch(domain:github.com)",
|
|
13
|
+
"WebFetch(domain:raw.githubusercontent.com)",
|
|
14
|
+
"WebFetch(domain:pypi.org)",
|
|
15
|
+
"Bash(PYTHONIOENCODING=utf-8 PYTHONUNBUFFERED=1 /c/Users/bertr/.local/bin/uv run python:*)",
|
|
16
|
+
"Bash(start \"\" \"C:\\\\Users\\\\bertr\\\\code\\\\interpreter\\\\debug_capture.png\")",
|
|
17
|
+
"Bash(start \"\" \"C:\\\\Users\\\\bertr\\\\code\\\\interpreter\\\\current_capture.png\")",
|
|
18
|
+
"Bash(git add:*)",
|
|
19
|
+
"Bash(git commit -m \"$\\(cat <<''EOF''\nAdd Windows support with DirectX capture\n\n- Use windows-capture library for Windows Graphics Capture API\n- Supports DirectX/OpenGL content capture from background windows\n- Add streaming capture interface for both Windows and macOS\n- Auto-detect fullscreen mode to skip title bar cropping\n- Fix overlay transparency and font for Windows\n- Fix CUDA fallback to CPU for translation\n- Add ''q'' hotkey to quit \\(Ctrl+C workaround on Windows\\)\n- Update default font size to 40\n\n🤖 Generated with [Claude Code]\\(https://claude.com/claude-code\\)\n\nCo-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>\nEOF\n\\)\")",
|
|
20
|
+
"Bash(git config:*)",
|
|
21
|
+
"Bash(git push:*)",
|
|
22
|
+
"WebSearch",
|
|
23
|
+
"WebFetch(domain:opennmt.net)",
|
|
24
|
+
"Bash(/c/Users/bertr/.local/bin/uv build:*)"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Binary
|
|
2
|
+
/interpreter
|
|
3
|
+
/interpreter.exe
|
|
4
|
+
|
|
5
|
+
# Models directory (downloaded on first run)
|
|
6
|
+
models/
|
|
7
|
+
|
|
8
|
+
# Python
|
|
9
|
+
__pycache__/
|
|
10
|
+
*.py[cod]
|
|
11
|
+
*$py.class
|
|
12
|
+
*.so
|
|
13
|
+
.Python
|
|
14
|
+
.venv/
|
|
15
|
+
venv/
|
|
16
|
+
ENV/
|
|
17
|
+
|
|
18
|
+
# IDE
|
|
19
|
+
.idea/
|
|
20
|
+
.vscode/
|
|
21
|
+
*.swp
|
|
22
|
+
*.swo
|
|
23
|
+
*.iml
|
|
24
|
+
|
|
25
|
+
# OS
|
|
26
|
+
.DS_Store
|
|
27
|
+
Thumbs.db
|
|
28
|
+
.env
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.11
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: interpreter-v2
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Offline screen translator for Japanese retro games
|
|
5
|
+
Author: qube
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: games,japanese,ocr,retro,translation
|
|
8
|
+
Requires-Python: >=3.11
|
|
9
|
+
Requires-Dist: ctranslate2
|
|
10
|
+
Requires-Dist: meikiocr
|
|
11
|
+
Requires-Dist: mss>=9.0.0
|
|
12
|
+
Requires-Dist: numpy
|
|
13
|
+
Requires-Dist: nvidia-cublas-cu12; sys_platform == 'win32'
|
|
14
|
+
Requires-Dist: nvidia-cudnn-cu12; sys_platform == 'win32'
|
|
15
|
+
Requires-Dist: onnxruntime-gpu; sys_platform == 'win32'
|
|
16
|
+
Requires-Dist: opencv-python
|
|
17
|
+
Requires-Dist: pillow>=10.0.0
|
|
18
|
+
Requires-Dist: pygetwindow>=0.0.9; sys_platform == 'win32'
|
|
19
|
+
Requires-Dist: pynput>=1.7.6
|
|
20
|
+
Requires-Dist: pyobjc-framework-quartz>=10.0; sys_platform == 'darwin'
|
|
21
|
+
Requires-Dist: pyyaml>=6.0
|
|
22
|
+
Requires-Dist: requests
|
|
23
|
+
Requires-Dist: sentencepiece
|
|
24
|
+
Requires-Dist: tqdm
|
|
25
|
+
Requires-Dist: windows-capture>=1.4.0; sys_platform == 'win32'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# Interpreter
|
|
29
|
+
|
|
30
|
+
Offline screen translator for Japanese retro games. Captures text from any window, performs OCR, translates to English, and displays subtitles in a floating overlay.
|
|
31
|
+
|
|
32
|
+

|
|
33
|
+
|
|
34
|
+
## Features
|
|
35
|
+
|
|
36
|
+
- **Fully offline** - No cloud APIs, no internet required after setup
|
|
37
|
+
- **Free** - No API costs or subscriptions
|
|
38
|
+
- **Private** - Text never leaves your machine
|
|
39
|
+
- **Optimized for retro games** - Uses MeikiOCR, trained specifically on Japanese game text
|
|
40
|
+
- **Two overlay modes** - Banner (subtitle bar) or inplace (text over game)
|
|
41
|
+
- **Translation caching** - Fuzzy matching avoids re-translating similar text
|
|
42
|
+
|
|
43
|
+
## Requirements
|
|
44
|
+
|
|
45
|
+
- Python 3.11+
|
|
46
|
+
- macOS (Windows/Linux support planned)
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
|
|
50
|
+
1. Install [uv](https://docs.astral.sh/uv/getting-started/installation/) (modern Python package manager):
|
|
51
|
+
```bash
|
|
52
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
2. Clone and install:
|
|
56
|
+
```bash
|
|
57
|
+
git clone https://github.com/bquenin/interpreter.git
|
|
58
|
+
cd interpreter
|
|
59
|
+
uv sync
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
3. Models are downloaded automatically on first run (~1.5GB total).
|
|
63
|
+
|
|
64
|
+
## Usage
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# List available windows
|
|
68
|
+
uv run interpreter --list-windows
|
|
69
|
+
|
|
70
|
+
# Run with default config
|
|
71
|
+
uv run interpreter
|
|
72
|
+
|
|
73
|
+
# Run with specific window
|
|
74
|
+
uv run interpreter --window "Tales"
|
|
75
|
+
|
|
76
|
+
# Start in inplace mode (text over game)
|
|
77
|
+
uv run interpreter --overlay-mode inplace
|
|
78
|
+
|
|
79
|
+
# Debug mode (show OCR confidence scores)
|
|
80
|
+
uv run interpreter --debug
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Controls
|
|
84
|
+
|
|
85
|
+
| Key | Action |
|
|
86
|
+
|-----|--------|
|
|
87
|
+
| `m` | Cycle overlay mode: off → banner → inplace |
|
|
88
|
+
| `-` | Decrease font size |
|
|
89
|
+
| `=` | Increase font size |
|
|
90
|
+
| `Ctrl+C` | Quit |
|
|
91
|
+
|
|
92
|
+
In banner mode, you can drag the overlay to reposition it.
|
|
93
|
+
|
|
94
|
+
## Overlay Modes
|
|
95
|
+
|
|
96
|
+
### Banner Mode (default)
|
|
97
|
+
A subtitle bar at the bottom of the screen displaying translated text. Draggable, opaque background, centered text.
|
|
98
|
+
|
|
99
|
+
### Inplace Mode
|
|
100
|
+
Transparent overlay positioned over the game window. Translated text appears directly over the original Japanese text at OCR-detected positions. Click-through so you can interact with the game.
|
|
101
|
+
|
|
102
|
+
## Configuration
|
|
103
|
+
|
|
104
|
+
Edit `config.yml`:
|
|
105
|
+
|
|
106
|
+
```yaml
|
|
107
|
+
# Window to capture (partial title match)
|
|
108
|
+
window_title: "Tales"
|
|
109
|
+
|
|
110
|
+
# Refresh rate in seconds
|
|
111
|
+
refresh_rate: 0.5
|
|
112
|
+
|
|
113
|
+
# OCR confidence threshold (0.0-1.0)
|
|
114
|
+
# Filters out garbage text by average per-line confidence
|
|
115
|
+
ocr_confidence: 0.6
|
|
116
|
+
|
|
117
|
+
# Subtitle appearance
|
|
118
|
+
font_size: 24
|
|
119
|
+
font_color: "#FFFFFF"
|
|
120
|
+
background_color: "#404040"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## How It Works
|
|
124
|
+
|
|
125
|
+
1. **Screen Capture** - Captures the target window at the configured refresh rate
|
|
126
|
+
2. **OCR** - [MeikiOCR](https://github.com/rtr46/meikiocr) extracts Japanese text (optimized for pixel fonts)
|
|
127
|
+
3. **Translation** - [Sugoi V4](https://huggingface.co/entai2965/sugoi-v4-ja-en-ctranslate2) translates Japanese to English
|
|
128
|
+
4. **Display** - Shows translated text in the selected overlay mode
|
|
129
|
+
|
|
130
|
+
## Troubleshooting
|
|
131
|
+
|
|
132
|
+
### Window not found
|
|
133
|
+
Use `--list-windows` to see available windows. The window title is a partial match.
|
|
134
|
+
|
|
135
|
+
### Poor OCR accuracy
|
|
136
|
+
Try adjusting `ocr_confidence` in config. Lower values include more text (but may include garbage), higher values are stricter.
|
|
137
|
+
|
|
138
|
+
### Slow performance
|
|
139
|
+
First run downloads models (~1.5GB). Subsequent runs use cached models from `~/.cache/huggingface/`.
|
|
140
|
+
|
|
141
|
+
## What's New in v2
|
|
142
|
+
|
|
143
|
+
- **Inplace overlay mode** - Text appears directly over game text
|
|
144
|
+
- **Mode cycling** - Press `m` to switch between off/banner/inplace
|
|
145
|
+
- **Font size adjustment** - Press `-`/`=` to resize on the fly
|
|
146
|
+
- **Translation caching** - Fuzzy matching reduces redundant translations
|
|
147
|
+
- **Improved OCR** - Punctuation excluded from confidence calculation
|
|
148
|
+
- **Better window capture** - Excludes overlapping windows, auto-detects fullscreen
|
|
149
|
+
- **Multi-display support** - Overlay appears on the same display as the game
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Interpreter
|
|
2
|
+
|
|
3
|
+
Offline screen translator for Japanese retro games. Captures text from any window, performs OCR, translates to English, and displays subtitles in a floating overlay.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Fully offline** - No cloud APIs, no internet required after setup
|
|
10
|
+
- **Free** - No API costs or subscriptions
|
|
11
|
+
- **Private** - Text never leaves your machine
|
|
12
|
+
- **Optimized for retro games** - Uses MeikiOCR, trained specifically on Japanese game text
|
|
13
|
+
- **Two overlay modes** - Banner (subtitle bar) or inplace (text over game)
|
|
14
|
+
- **Translation caching** - Fuzzy matching avoids re-translating similar text
|
|
15
|
+
|
|
16
|
+
## Requirements
|
|
17
|
+
|
|
18
|
+
- Python 3.11+
|
|
19
|
+
- macOS (Windows/Linux support planned)
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
1. Install [uv](https://docs.astral.sh/uv/getting-started/installation/) (modern Python package manager):
|
|
24
|
+
```bash
|
|
25
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
2. Clone and install:
|
|
29
|
+
```bash
|
|
30
|
+
git clone https://github.com/bquenin/interpreter.git
|
|
31
|
+
cd interpreter
|
|
32
|
+
uv sync
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
3. Models are downloaded automatically on first run (~1.5GB total).
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# List available windows
|
|
41
|
+
uv run interpreter --list-windows
|
|
42
|
+
|
|
43
|
+
# Run with default config
|
|
44
|
+
uv run interpreter
|
|
45
|
+
|
|
46
|
+
# Run with specific window
|
|
47
|
+
uv run interpreter --window "Tales"
|
|
48
|
+
|
|
49
|
+
# Start in inplace mode (text over game)
|
|
50
|
+
uv run interpreter --overlay-mode inplace
|
|
51
|
+
|
|
52
|
+
# Debug mode (show OCR confidence scores)
|
|
53
|
+
uv run interpreter --debug
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Controls
|
|
57
|
+
|
|
58
|
+
| Key | Action |
|
|
59
|
+
|-----|--------|
|
|
60
|
+
| `m` | Cycle overlay mode: off → banner → inplace |
|
|
61
|
+
| `-` | Decrease font size |
|
|
62
|
+
| `=` | Increase font size |
|
|
63
|
+
| `Ctrl+C` | Quit |
|
|
64
|
+
|
|
65
|
+
In banner mode, you can drag the overlay to reposition it.
|
|
66
|
+
|
|
67
|
+
## Overlay Modes
|
|
68
|
+
|
|
69
|
+
### Banner Mode (default)
|
|
70
|
+
A subtitle bar at the bottom of the screen displaying translated text. Draggable, opaque background, centered text.
|
|
71
|
+
|
|
72
|
+
### Inplace Mode
|
|
73
|
+
Transparent overlay positioned over the game window. Translated text appears directly over the original Japanese text at OCR-detected positions. Click-through so you can interact with the game.
|
|
74
|
+
|
|
75
|
+
## Configuration
|
|
76
|
+
|
|
77
|
+
Edit `config.yml`:
|
|
78
|
+
|
|
79
|
+
```yaml
|
|
80
|
+
# Window to capture (partial title match)
|
|
81
|
+
window_title: "Tales"
|
|
82
|
+
|
|
83
|
+
# Refresh rate in seconds
|
|
84
|
+
refresh_rate: 0.5
|
|
85
|
+
|
|
86
|
+
# OCR confidence threshold (0.0-1.0)
|
|
87
|
+
# Filters out garbage text by average per-line confidence
|
|
88
|
+
ocr_confidence: 0.6
|
|
89
|
+
|
|
90
|
+
# Subtitle appearance
|
|
91
|
+
font_size: 24
|
|
92
|
+
font_color: "#FFFFFF"
|
|
93
|
+
background_color: "#404040"
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## How It Works
|
|
97
|
+
|
|
98
|
+
1. **Screen Capture** - Captures the target window at the configured refresh rate
|
|
99
|
+
2. **OCR** - [MeikiOCR](https://github.com/rtr46/meikiocr) extracts Japanese text (optimized for pixel fonts)
|
|
100
|
+
3. **Translation** - [Sugoi V4](https://huggingface.co/entai2965/sugoi-v4-ja-en-ctranslate2) translates Japanese to English
|
|
101
|
+
4. **Display** - Shows translated text in the selected overlay mode
|
|
102
|
+
|
|
103
|
+
## Troubleshooting
|
|
104
|
+
|
|
105
|
+
### Window not found
|
|
106
|
+
Use `--list-windows` to see available windows. The window title is a partial match.
|
|
107
|
+
|
|
108
|
+
### Poor OCR accuracy
|
|
109
|
+
Try adjusting `ocr_confidence` in config. Lower values include more text (but may include garbage), higher values are stricter.
|
|
110
|
+
|
|
111
|
+
### Slow performance
|
|
112
|
+
First run downloads models (~1.5GB). Subsequent runs use cached models from `~/.cache/huggingface/`.
|
|
113
|
+
|
|
114
|
+
## What's New in v2
|
|
115
|
+
|
|
116
|
+
- **Inplace overlay mode** - Text appears directly over game text
|
|
117
|
+
- **Mode cycling** - Press `m` to switch between off/banner/inplace
|
|
118
|
+
- **Font size adjustment** - Press `-`/`=` to resize on the fly
|
|
119
|
+
- **Translation caching** - Fuzzy matching reduces redundant translations
|
|
120
|
+
- **Improved OCR** - Punctuation excluded from confidence calculation
|
|
121
|
+
- **Better window capture** - Excludes overlapping windows, auto-detects fullscreen
|
|
122
|
+
- **Multi-display support** - Overlay appears on the same display as the game
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# OCR Benchmark
|
|
2
|
+
|
|
3
|
+
This folder contains test data and scripts for benchmarking OCR accuracy on Japanese game text.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
benchmark/
|
|
9
|
+
├── data/ # Test cases
|
|
10
|
+
│ ├── 001_miguel_pendant/
|
|
11
|
+
│ │ ├── textbox.png # Cropped textbox image (required)
|
|
12
|
+
│ │ ├── screenshot.png # Full game screenshot (optional, for future textbox detection)
|
|
13
|
+
│ │ ├── ground_truth.txt # Expected OCR output (required)
|
|
14
|
+
│ │ └── textbox_coords.json # Textbox location in screenshot (optional)
|
|
15
|
+
│ └── ...
|
|
16
|
+
├── results/ # Benchmark results (JSON)
|
|
17
|
+
├── run_benchmark.py # Benchmark script
|
|
18
|
+
└── README.md
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Running Benchmarks
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Run full benchmark (all engines, all preprocessing)
|
|
25
|
+
python benchmark/run_benchmark.py
|
|
26
|
+
|
|
27
|
+
# Run specific engine
|
|
28
|
+
python benchmark/run_benchmark.py --engine meikiocr
|
|
29
|
+
|
|
30
|
+
# Run specific preprocessing
|
|
31
|
+
python benchmark/run_benchmark.py --preprocessing otsu
|
|
32
|
+
|
|
33
|
+
# Save results to JSON
|
|
34
|
+
python benchmark/run_benchmark.py --save
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Adding New Test Cases
|
|
38
|
+
|
|
39
|
+
1. Create a new folder in `benchmark/data/` with format `NNN_description/`:
|
|
40
|
+
```
|
|
41
|
+
benchmark/data/003_my_test_case/
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
2. Add required files:
|
|
45
|
+
- `textbox.png` - Cropped image of the textbox only
|
|
46
|
+
- `ground_truth.txt` - Expected OCR output (exact text)
|
|
47
|
+
|
|
48
|
+
3. Optionally add:
|
|
49
|
+
- `screenshot.png` - Full game screenshot
|
|
50
|
+
- `textbox_coords.json` - Bounding box coordinates for textbox detection testing
|
|
51
|
+
|
|
52
|
+
4. Run benchmark to verify:
|
|
53
|
+
```bash
|
|
54
|
+
python benchmark/run_benchmark.py --save
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## OCR Engines
|
|
58
|
+
|
|
59
|
+
| Engine | Description |
|
|
60
|
+
|--------|-------------|
|
|
61
|
+
| `manga_ocr` | VisionEncoderDecoder model for manga text |
|
|
62
|
+
| `meikiocr` | ONNX model trained on Japanese video game text |
|
|
63
|
+
|
|
64
|
+
## Preprocessing Methods
|
|
65
|
+
|
|
66
|
+
| Method | Description |
|
|
67
|
+
|--------|-------------|
|
|
68
|
+
| `none` | No preprocessing, raw image |
|
|
69
|
+
| `otsu` | Otsu binarization only |
|
|
70
|
+
| `4x_lanczos` | 4x upscaling with LANCZOS interpolation |
|
|
71
|
+
| `4x_otsu` | 4x upscaling + Otsu binarization |
|
|
72
|
+
| `4x_otsu_invert` | 4x upscaling + Otsu + auto-invert |
|
|
73
|
+
|
|
74
|
+
## Results Format
|
|
75
|
+
|
|
76
|
+
Results are saved as JSON with this structure:
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"timestamp": "2024-12-29T00:00:00",
|
|
81
|
+
"engines": ["manga_ocr", "meikiocr"],
|
|
82
|
+
"preprocessing": ["none", "otsu", ...],
|
|
83
|
+
"test_cases": ["001_miguel_pendant", ...],
|
|
84
|
+
"results": [
|
|
85
|
+
{
|
|
86
|
+
"test_case": "001_miguel_pendant",
|
|
87
|
+
"engine": "meikiocr",
|
|
88
|
+
"preprocessing": "otsu",
|
|
89
|
+
"output": "...",
|
|
90
|
+
"ground_truth": "...",
|
|
91
|
+
"accuracy": 95.2
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Current Best Configuration
|
|
98
|
+
|
|
99
|
+
Based on benchmarking: **MeikiOCR + Otsu** achieves ~86% average accuracy.
|
|
100
|
+
|
|
101
|
+
| Engine | Preprocessing | Average Accuracy |
|
|
102
|
+
|--------|---------------|------------------|
|
|
103
|
+
| MeikiOCR | Otsu | ~86% |
|
|
104
|
+
| MeikiOCR | None | ~80% |
|
|
105
|
+
| manga_ocr | 4x+Otsu+Invert | ~85% |
|
|
106
|
+
| manga_ocr | None | ~49% |
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ミゲール「お前にやったペンダントについてな。
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
クレス「ペンダント?ああ、15の誕生日にもらった・・・・。あれがどうしたの?」
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
チェスター「それじゃ狩りに行ってくるよ、アミィ。
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
アミィ「気をつけてね、お兄ちゃん。
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
チェスター「クレス、行くぞ!
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ミゲール「あの声はチェスターか。
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
クレス「あ、父さんごめん。チェスターと約束してたんだ。
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ミゲール「ああ。ペンダントのことは夕食の時にでも話そう。
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
トリスタン師匠、ゆっくりしてって下さい。
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
クレス「悪い悪い。今、師匠が家に来ててね。じゃあ行こうか、チェスター。
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
母マリア「お待ちなさい、クレス。
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
クレス「母さん!まだ病み上がりなんだから外に出ちゃダメだよ。
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
母マリア「でも、お前が心配でね。最近この辺りは物騒だから………。
|