How 45ngc/boardsnap works
BoardSnap is a Python chessboard image-recognition package with a JSON CLI for digital-board profiles and an experimental book-diagram profile. The main workflow accepts a local image, detects and normalizes its board, splits squares, resolves orientation, classifies pieces, and returns FEN-style piece placement; CLI adapts results and errors. Separate repository tools support annotated capture, frozen position plans, square-dataset preparation, and an optional PyTorch classifier. Edges follow the sampled pipeline and explicit README capabilities; capture/data-tool internals are represented conservatively where implementation was not fully sampled.
Main entry points: pipeline.py Recognition pipeline · neural.py Optional neural inference · capture_lichess.py Annotated capture · orientation.py Orientation reading
Components 20
User interface
- JSON CLI
src/boardsnap/adapters/cli.py - Recognition pipeline
src/boardsnap/pipeline.py
Recognition stages
- Image decoding
src/boardsnap/image_input.py - Board detection
src/boardsnap/detection.py - Board normalization
src/boardsnap/normalization.py - Square segmentation
src/boardsnap/segmentation.py - Orientation reading
src/boardsnap/orientation.py - Placement encoding
src/boardsnap/output.py
Profiles and classifiers
- Template recognition
src/boardsnap/classification.py - Recognition profiles
src/boardsnap/profiles.py - Shipped templates
src/boardsnap/assets - Optional neural inference
src/boardsnap/neural.py
Dataset workflows
- Annotated capture
tools/capture_lichess.py - Configurable capture
tools/capture_batch.py - Position planning
tools/position_dataset.py - Square dataset
tools/build_square_dataset.py - Neural dataset
tools/neural_data.py - Clean corpus
tools/collect_clean_corpus.py
Other components
- Image user
- Lichess editor
Connections 27
- Image user → JSON CLI: submits image
README.md - JSON CLI → Recognition pipeline: invokes
src/boardsnap/adapters/cli.py - Recognition pipeline → Image decoding: reads image
src/boardsnap/pipeline.py - Recognition pipeline → Board detection: detects board
src/boardsnap/pipeline.py - Recognition pipeline → Board normalization: normalizes bounds
src/boardsnap/pipeline.py - Recognition pipeline → Square segmentation: splits squares
src/boardsnap/pipeline.py - Recognition pipeline → Orientation reading: resolves view
src/boardsnap/pipeline.py - Recognition pipeline → Template recognition: classifies squares
src/boardsnap/pipeline.py - Recognition pipeline → Placement encoding: encodes placement
src/boardsnap/pipeline.py - Template recognition → Recognition profiles: loads profile
src/boardsnap/classification.py - Orientation reading → Recognition profiles: loads profile
src/boardsnap/orientation.py - Template recognition → Shipped templates: loads piece assets
src/boardsnap/classification.py - Orientation reading → Shipped templates: loads glyph assets
src/boardsnap/orientation.py - Optional neural inference → Image decoding: reads image
src/boardsnap/neural.py - Optional neural inference → Board detection: detects board
src/boardsnap/neural.py - Optional neural inference → Board normalization: normalizes bounds
src/boardsnap/neural.py - Optional neural inference → Square segmentation: splits squares
src/boardsnap/neural.py - Optional neural inference → Placement encoding: encodes placement
src/boardsnap/neural.py - Lichess editor → Annotated capture: provides board
README.md - Annotated capture → Position planning: validates plan
tools/capture_lichess.py - Configurable capture → Position planning: uses plan
tools/capture_batch.py - Configurable capture → Annotated capture: collects captures
tools/capture_batch.py - Annotated capture → Clean corpus: supplies captures
README.md - Clean corpus → Square dataset: prepares crops
tools/build_square_dataset.py - Position planning → Square dataset: validates sources
tools/build_square_dataset.py - Square dataset → Neural dataset: provides squares
tools/neural_data.py - Neural dataset → Optional neural inference: supports training
README.md