https://github.com/daniel-lima-lopez/chess-pieces-classification-with-area-correlation
This repository describes a technique for classifying chess pieces based on area correlation and the kNN classifier.
https://github.com/daniel-lima-lopez/chess-pieces-classification-with-area-correlation
chess classification knn
Last synced: 17 days ago
JSON representation
This repository describes a technique for classifying chess pieces based on area correlation and the kNN classifier.
- Host: GitHub
- URL: https://github.com/daniel-lima-lopez/chess-pieces-classification-with-area-correlation
- Owner: daniel-lima-lopez
- Created: 2023-08-04T20:10:22.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-05T23:04:59.000Z (almost 2 years ago)
- Last Synced: 2025-02-07T01:45:44.581Z (5 months ago)
- Topics: chess, classification, knn
- Language: Python
- Homepage:
- Size: 747 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Chess pieces classification with area correlation
[Versión en español](README_ES.md)In this repository, is presented a simple method to classify chess pieces on a board. Unlike traditional deep learning-based approaches, the problem is approached using area correlation and k-NN classifier, which allows us to implement a straightforward and intuitive method that performs well in controlled environments.
## Method description
The classification is carried out using the information of each piece's area. To gather such information, we work with boards from the page. [Chess](https://www.chess.com/es):
To build the dataset to work with _k-NN_ classifier, the board image is binarized, and the information of each square is divided:

Subsequently, for each piece, the image is divided into windows, and the number of black pixels in each window is counted:

Consequently, we obtain nine-entry vectors that represent the information of each piece.
Each board is processed using the method described above to calculate the area of each square, finally, *k-NN* is used to predict the most similar piece for each square and assign a label:

## Instalation
Clone or download this repository:
```bash
git clone [email protected]:daniel-lima-lopez/Chess-pieces-classification-with-area-correlation.git
```## Example
To instantiate the classifier, it is necessary to import the class:
```python
from ChessClassifier import Classifierclassifier = Classifier()
```Subsequently, to make a prediction, you must include the location of the board to be classified.:
```python
classifier.predict('path')
```
Example [boards](test/) are included to test the classifier.