10000 GitHub - AlexTran448/chessai: Chinese Chess Advanced Analytics with ChessBoard Detection
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

AlexTran448/chessai

 
 

Repository files navigation

Fork of ChessAI - Chinese Chess Game Analyzer

Features added to this fork

Added button to start aligning the board Added Deep learning model for chess board detection (No need to use ARUCO markers)

Method

  • Find estimate of board using Yolov8 model
  • Use estimation to find an initial alignment of the board
  • Binarise using canny image
  • Hide pieces from the image to avoid
  • Use Hough transformation to find the lines
  • Group lines that are close together (likely to be part of the same line)
  • Finding intersections of each line
  • Loop through arbitarily chosen intersections (created by 2 vertical and 2 horizontal lines) and compare to other intersections
  • Select the best 4 intersections that leads to the largest number other intersections matching the estimated board
  • Use intersections to create new more accurate alignment

Why not use only Yolov8

Few datasets are avaliable, making it difficult to make the model perfect. Data augmentation was used to give the model more robustness against rotation and other transformations. Despite this, there were few lighting situations where using Yolo produced poor results

TODO

[ ] Generate more diverse dataset to allow for more board types to be used [ ] Automatically check when board has been moved and automatically start aligning the board [ ] Change model for detecting pieces to use the whole piece instead of just the piece's character (When board is placed at a low angle, the piece face does not align with the correct position, this solution will fix it)

Weaknesses

Problem: Board detection model performs poorly against board that are far from camera

  • Likely cause: dataset contained boards that were all close to the board
  • Solution: Include datasets where the board is at far distances from the camera or augment data to change the board's size

Problem: Board detection model falsely detects objects such as chessboards

  • Likely cause: dataset didn't contain many null examples
  • Solution: Incluide chessboards, and other objects that were commonly missclassified to training set

-------------------

Upstream README.md at start of fork

ChessAI is a groundbreaking tool that brings together computer vision, chess algorithms, and advanced analytics to revolutionize the Chinese Chess analytics landscape. With ChessAI, you don't need expensive electronic boards to analyze your games. Simply use your regular board, set up a camera to capture the position, and let ChessAI do the rest.

  • Main source code: chesssai.
  • Deep Learning / Data Preparation: dnn_models/data_preparation - Currenly only support for Chinese Chess (XiangQi), contact me for the license and the source code of the data preparation tool.
  • Deep Learning / Training: dnn_models/training.

ChessAI

Roadmap

  • Chess position detection.
  • Chess engine integration.
  • Move suggestion.
  • Deep learning model for chess board detection (No need to use ARUCO markers).

Environment setup

  • Requirements: Python 3.9, Conda, Node.js 18+.
  • Clone this repository.
git clone https://github.com/vietanhdev/chessai --recursive
  • Create a new conda environment and the required packages.
conda create -n chessai python=3.9
conda activate chessai
pip install -e .
  • Install Node.js packages and build the frontend.
cd chessai/frontend
npm install
cd ..
bash build_frontend.sh

Build chess engine

  • This project uses godogpaw as the chess engine.
  • Install Go.
  • Build the engine.
cd godogpaw
go build

Run the app

ENGINE_PATH="data/engines/godogpaw-macos-arm" python -m chessai.app --run_app

Replace ENGINE_PATH with the path to the chess engine executable file.

Data preparation & Training

This project uses computer vision and deep learning to detect chess pieces and chess board position.

AI flow for chess position detection:

AI flow for chess position detection

  • Go to dnn_models folder and follow the instructions in the README.md file to prepare the data and train the model.
  • NOTE: Only training source code and pretrained models are included in this repository. The data preparation scripts and the training datset are not included. Contact me for the license and the data.

References

About

Chinese Chess Advanced Analytics with ChessBoard Detection

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 50.1%
  • TypeScript 45.4%
  • C++ 3.5%
  • Other 1.0%
0