A computer vision application that recognizes chess positions from screenshots and provides engine analysis. Combines deep learning, computer vision, and chess engine integration into a cross-platform pipeline.
Screen Capture → Chessboard Detection → Grid Segmentation → CNN Inference → FEN Generation → Stockfish Analysis
Input: Cross-platform screen capture (mss on Linux/Mac, win32gui on Windows) with automatic browser window detection.
Vision: Chessboard detection via OpenCV (Canny edge detection, contour analysis), 8×8 grid segmentation with coordinate mapping (A1-H8), image preprocessing (100×100 normalization).
Inference: Custom CNN model (TensorFlow/Keras) for 13-class piece classification (6 black pieces, 6 white pieces, empty square).
Engine: FEN generation from predictions using python-chess, Stockfish integration for evaluation and best move calculation.
- Python 3.10+
- Stockfish binary (download)
-
Clone and setup environment:
git clone <repository-url> cd chess-vision-tf python -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate pip install -r requirements.txt
-
Install Stockfish binary:
- Place executable in
engines/directory:- Windows:
engines/stockfish.exe - Linux/Mac:
engines/stockfish
- Windows:
- Or ensure Stockfish is in system PATH
- Place executable in
-
Place trained model at
models/model.h5
Windows: Automatically detects and captures browser windows.
Linux/Mac: Captures primary monitor by default. For window-specific capture, install xdotool or wmctrl.
python main.pyTwo input methods:
- Screenshot Analysis: Captures screen, detects chessboard, classifies pieces, opens analysis window
- FEN Input: Directly load a position using Forsyth-Edwards Notation
MIT License - see LICENSE file for details.

