This is a Smart System project that:
- Applies Artificial Intelligence
- Applies Embedded programming
- Applies Internet of Things With the purpose of assisting human making decisions.
The system consists of 3 steps:
- Monitors the chessboard, taking picture every few millisecs.
- Recognizes the pieces, understands the chess board position. Then, search and calculate for the next best moves.
- Broadcast those information over LAN via wi-fi. The system has a dedicated web-server to display these information.
As you may know, the hard task is in Step 2, which will be described below.
The problem CCA has to solve can be summed up as follow: "Provided a picture frame that contains a game of Chinese chess, please suggest the next best moves for the two players."
Based on the above problem, the solution must solve these subtasks:
- The computer understands the board. (Solved using Computer vision with a Tensorflow Classifier model)
- The computer suggests chess moves. (Solved using a chinese chess engine as backend with some modifications)
Here we will describe only the first subtask.
The taken frame will first go through preprocess phase to better isolate the board from the rest of the images. This preprocess has 3 steps:
- Find mask of the board
- Find contour and four corners
- Perspective transform
Below is an example of a frame going through preprocessing:
After obtaining the top-down view of the board, we attempt to retrieve each position on the board by cutting the image using vertical and horizontal lines. There are total 90 positions on the board. Next, we will use a classifier model (which was specifically made an trained for this taks) to recognize the symbols on the pieces. Below is an example.
Lastly, we pass the board to the engine to retrieve the suggestions.
Our project were deployed on a Raspberry Pi 3B. This device also has a small webserver that is used to deliver/broadcast the current chess game to other devices that connect to the server. If you are wondering how the system runs, please take a look into threaded_webserver.py
.
- We did a small video to demonstate our project/system here.
- For more on preprocessing, checkout dev-boardPreprocess branch
- For more on piece recognition, checkout dev-pieceRecognition branch
- Please check out our report here (Vietnamese and English) if you are interested.
- The Chinese Chess Engine that made it possible elephantfish.py. Please go and give them a star!