ChessSense is a chessboard recognition tool that automates piece detection from images captured from the screen in real-time. With computer vision, it accurately identifies chessboard layouts and piece positions and generates a FEN notation of the current position to recommend the next best move.
ChessSense.Demo.mp4
For the purposes of this project, all the chess images were taken from chess.com, more particularly the Neo pieces and the Green board configuration. Therefore, prior to using the application configure the corresponding settings.
./board_templates
: Is the folder that contains all relevant chess board templates used for training and performing image processing tasks.
./pieces
: Contains two subfolders having the images of the black and white pieces with varying background colours.
./resized_pieces
: A copy of the above mentioned folder with resized images to perform template matching through image processing and computer vision.
./thresholds
: Plots to define the colour values and thresholds to distimguish white and black pieces.
app.py
is the executable application.
board_lines.py
used to detect the individual cells in a chess board.
detect_board.py
used to detect the chess board based on the images passed. Performs IP tasks such as countouring and can save intermediate image files in a new folder.
fen_notation.py
generates the FEN notation through the positions of the pieces identified in the chessboard.
get_best_move.py
predicts the next optimal move by passing the FEN string to a Stockfish 16 engine.
image_augmentation.py
and image_resizing.py
to augment and process images to suitable sizes for image processing.
recognize_pieces.py
to identify the pieces on a chessboard and their corresponding positions.
I have not yet made the application and the corresponding APIs available to the public. The purpose of this project was to use image processing and computer vision to automate the process of playing and learning chess by recommending the best moves. If anyone is willing to access the application, they can do so by following the below steps.
- Clone this repository
git clone https://github.com/Dhruv16S/ChessSense.git
- Install required dependencies through
pip install -r requirements.txt
- Run the application
python app.py