This project involves loading multiple images of chess boards and utilizing the matchTemplate method of OpenCV to detect the pieces present on each board. As a result of this process, the output includes a comprehensive list of the detected chess piece names.
- Python 3.x
- OpenCV
- Numpy
To get started, first clone the repository and install the necessary dependencies by running the following command:
pip install opencv-python numpy
Next, place the chess board image files in the test/
directory and the chess piece image files in the chess_piece/
directory.
There are two ways to execute the program:
Method 1: Running in Terminal
To run the script in the terminal, use the following command:
python main.py
Method 2: Running in Jupyter Lab
To run the script in Jupyter Lab
, open the main.ipynb
notebook and execute the code.
The following configurations can be adjusted according to the user's preference:
SHOW_IMAGE
: If set toTrue
, the image with detected pieces will be displayed. Default isTrue
.EXPORT_IMAGE
: If set toTrue
, the image with detected pieces will be saved to thedist/
directory. Default isTrue
.chessPieceThreshold
: The threshold values for each chess piece can be adjusted according to the image quality. The default values are provided in the script.CHESS_BOARD_OUTPUT_DIR
: The directory where the output images will be saved. Default isdist/
.
This project is licensed under the MIT License.