Japanese text can be written vertically (tategaki, 縦書き) — top-to-bottom, right-to-left columns. This is the standard layout in manga, many games, and traditional Japanese documents. If you're building an OCR-based translation tool for Android, handling vertical text is one of the trickiest challenges you'll face.
The Problem
Most OCR engines are optimized for horizontal left-to-right text. When you feed them a manga page with vertical Japanese text, you get:
- Garbled character order
- Merged text from adjacent columns
- Missing characters at column boundaries
- Completely wrong reading direction
Detection Strategies
1. Aspect Ratio Analysis
Vertical text blocks tend to be taller than wide. If a detected text region has a height-to-width ratio > 2:1, it's likely vertical text.
2. Character Spacing Patterns
In vertical text, characters are stacked with consistent vertical spacing. Analyze the spatial distribution of detected characters — if they cluster along vertical axes, rotate the region 90° before OCR.
3. ML Kit's Built-in Support
Google's ML Kit (used in many Android OCR apps) has improved vertical text support in recent versions. The TextRecognition API with the Japanese script recognizer handles vertical text reasonably well out of the box.
Practical Solution: Screen Translator's Approach
In Screen Translator, we handle vertical Japanese text with a multi-step pipeline:
- Capture — MediaProjection API captures the screen
- Pre-process — Detect text regions and analyze orientation
- Rotate if needed — Vertical regions get rotated 90° CW
- OCR — Run text recognition on normalized images
- Post-process — Reorder characters to correct reading order
- Translate — Send properly ordered text to translation API
Tips for Developers
- Always test with real manga pages, not just synthetic test images
- Japanese text in games often uses custom fonts that reduce OCR accuracy
- Furigana (small reading aids above kanji) can confuse OCR — consider filtering by text size
- Mixed horizontal/vertical layouts (common in manga) need per-region orientation detection
Results
With proper vertical text handling, OCR accuracy on manga pages jumps from ~40% to ~85%+ for clean digital scans. The key insight is that text orientation detection must happen before OCR, not after.
If you're working on similar problems, I'd love to hear your approach. Drop a comment below!
Screen Translator is a free floating overlay translator for Android that handles vertical Japanese text, manga, games, and more: Google Play
Top comments (0)