A Python-based Omaha Poker OCR Analyzer that uses optical character recognition (OCR) to detect and analyze poker hands from screenshots of online poker games. The system captures cards during different phases of play (preflop, flop, turn, river) and provides game state tracking.
src/
βββ game/
β βββ __init__.py
β βββ game.py
β βββ player.py
β βββ core/
β βββ __init__.py
β βββ card.py
β βββ deck.py
β βββ hand_evaluator.py
- OCR Card Detection: Automatically detects cards from poker table screenshots
- Multi-Phase Support: Captures cards during preflop, flop, turn, and river
- Visual Calibration Tool: Easy setup for your specific poker client and screen resolution
- Configuration Management: Centralized config file for all settings
- Game State Tracking: Full Omaha poker game logic with player and table management
- Color-Based Suit Detection: Identifies card suits using RGB color sampling
- Tesseract Integration: Robust text recognition for card ranks
-
Install Tesseract OCR:
- Windows: Download from GitHub
- macOS:
brew install tesseract - Linux:
sudo apt-get install tesseract-ocr
-
Python 3.7+
-
Clone the repository and navigate to the project directory
-
Create a virtual environment:
python -m venv .venv- Activate the virtual environment:
# On Windows
.venv\Scripts\activate
# On Unix or MacOS
source .venv/bin/activate- Install dependencies:
pip install -r requirements.txt- Configure Tesseract path and card positions:
- Copy
config.yamltoconfig.local.yaml - Update the Tesseract path in
config.local.yaml - Run calibration tool to set card positions (see below)
- Copy
Before using the OCR analyzer, you need to calibrate the card positions for your poker client:
# Install matplotlib if not already installed
pip install matplotlib
# Run the visual calibration tool
python calibrate_positions_visual.pyClick on the screenshot to select card positions. See CALIBRATION_GUIDE.md for detailed instructions.
python calibrate_positions.pyEnter coordinates manually. See CALIBRATION_GUIDE.md for detailed instructions.
python run_game_gui.pyThe GUI provides:
- Visual interface showing current phase
- "Capture Cards" button to take screenshot and detect cards
- Real-time display of detected cards (hand, flop, turn, river)
- Automatic phase progression
- Reset button to start over
python run_game.pyThe terminal analyzer will:
- Wait for you to press Enter at each poker phase
- Capture a screenshot of your poker table
- Detect cards using OCR based on the current phase:
- Preflop: Your hole cards
- Flop: Your hole cards + 3 flop cards
- Turn: Turn card
- River: River card
- Save cropped card images to
card_crops/for review - Display detected cards in the console
from ocr_reader import (
detect_hand_from_image,
read_flop_from_image,
read_turn_from_image,
read_river_from_image
)
# Detect hole cards
hand = detect_hand_from_image("screenshot.png")
# Returns: [{'number': 'A', 'shape': 'hearts', ...}, ...]
# Detect flop cards
flop = read_flop_from_image("screenshot.png")
# Returns: [card1, card2, card3]
# Detect turn card
turn = read_turn_from_image("screenshot.png")
# Returns: {'number': 'K', 'shape': 'spades', ...}
# Detect river card
river = read_river_from_image("screenshot.png")
# Returns: {'number': '9', 'shape': 'diamonds', ...}All settings are in config.yaml. Create config.local.yaml to override defaults without affecting version control.
Key configuration options:
- tesseract.path: Path to Tesseract executable
- card_locations: Screen coordinates for each card position
- suit_colors: RGB values for suit color detection
- ocr.threshold: Binarization threshold for OCR preprocessing
- ocr.padding: Padding around card images
- ocr.psm_mode: Tesseract PSM mode (default: 10 for single character)
hutishtuti/
βββ config.yaml # Default configuration
βββ ocr_reader.py # OCR card detection functions
βββ run_game_gui.py # GUI entry point (recommended)
βββ run_game.py # Terminal entry point
βββ calibrate_positions.py # Manual calibration tool
βββ calibrate_positions_visual.py # Visual calibration tool
βββ CALIBRATION_GUIDE.md # Detailed calibration instructions
βββ src/
β βββ config.py # Configuration loader
β βββ game/
β βββ game.py # Game state management
β βββ player.py # Player classes
β βββ table.py # Table/pot management
β βββ core/
β βββ card.py # Card, Suit, Rank definitions
β βββ hand_evaluator.py # Hand evaluation logic
βββ requirements.txt
- Run the calibration tool to verify card positions
- Check
card_crops/folder to see what the OCR is seeing - Adjust coordinates in
config.yamlif crops look wrong - Ensure Tesseract path is correct in config
- Check OCR threshold setting in config (try 170-190)
- Verify card crops include the rank clearly
- Make sure poker client cards are visible and not obscured
- Ensure card crops include some colored pixels
- Adjust
suit_colorsRGB values in config for your poker client's color scheme
The project uses a modular architecture:
- OCR Layer: Card detection and image processing
- Game Logic: Poker game state and rules
- Configuration: Centralized settings management
Run tests using pytest:
pytestThis project is for educational and personal use.