0% found this document useful (0 votes)
65 views

Chess Vision

This document summarizes the final project report for a chess vision system. The system uses computer vision and deep learning techniques to recognize the chessboard, pieces, and detect new moves from camera images in real-time. It then integrates with a web app to suggest the best next move and provide move legality feedback to the user. Key components include hand and chessboard recognition, piece classification, move detection, and a Flask-based web app interface with SocketIO for real-time updates. The system was trained on sample images and utilizes libraries like Python-chess, OpenCV, and Stockfish to analyze board positions and generate move suggestions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views

Chess Vision

This document summarizes the final project report for a chess vision system. The system uses computer vision and deep learning techniques to recognize the chessboard, pieces, and detect new moves from camera images in real-time. It then integrates with a web app to suggest the best next move and provide move legality feedback to the user. Key components include hand and chessboard recognition, piece classification, move detection, and a Flask-based web app interface with SocketIO for real-time updates. The system was trained on sample images and utilizes libraries like Python-chess, OpenCV, and Stockfish to analyze board positions and generate move suggestions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 63

Chess Vision

Final project report


2
3
4
5
6
7
Hand Chessboard Pieces New move Update web
recognition recognition classifiction detection app UI
•Detect •Extract 64 •Identify •understand •Best move
desired squares each square when a new suggestion
engine level content board state & legallity
is present feedback

8
9
10



11
12
13
14
15
16
17
18
19
20
21
22
23
24
detectChessBoard -

detectCheckerboardPoints

GetOnlyBoard tform =
fitgeotrans(movingPoints,fixedPoints, projective)

25
img2meansquares

26
GetNextFrame2

GetOnlyBoard .

27
GetNextFrame2
GetNewPositions2

28
GetNewPositions2
GetNextFrame2.

29
Keeping Keeping 60% Empty square Max diff that is
Squares from max diff classifiction an empty
contain current value square
player pieces

30
31
Ignoring Keeping 60% Empty square Choosing the
Squares from max diff classifiction highest
contain prev value predction score
player pieces

32
33
34
35
36
37
38
39
40
41
{'b','bb','nn','n','p','pp','q','ee','e','qq','r','r
r','k','kk'}.

[trainingSet, validationSet] = splitEachLabel(imds,


0.85, 'randomize');

42
trainImageCategoryClassifier

43
44
45
46
47
48
49
50
51
52
53
54
55
56
def king_squaree_ifcheck(self):
# Custom function - if the current side is in
check return the king square
check = self.king(self.turn) if self.is_check()
else None
return check

def getMoveAttribute(move_str, square_number):


"""input: move_str = uci move e.g.
'e2e4',square_number : 0/1 for the first/second
square"""
"""output: chess.E2 / chess.E4 attribute for
drawing arrow on this move"""

str = move_str[0 + square_number * 2:2 +


square_number * 2]
return getattr(chess, str.upper())

57
def writeMove():
"""Write the current engine suggestion to the
EngineMoves txt file"""
global currentBestMove
m = open(file_to_write, 'a')
m.write(currentBestMove + '\n')
m.close()

//receive board state from server


socket.on('newmove', function(msg) {
console.log("Received board" + msg.board);
$('#board').html(msg.board);
});

pip install flask-socketio


pip install flask
pip install threading
pip install python-chess

from flask_socketio import SocketIO, emit


from flask import Flask, render_template, url_for,
copy_current_request_context
from random import random
from time import sleep
from threading import Thread, Event
import chess
import chess.uci
import chess.svg
import sys

58
59
60
61
1. Cheryl Danner & Mai Kafafy. Visual Chess Recognition. Stanford University

2. A Czyzewski, Maciej & Laskowski, Artur & Wasik, Szymon. (2018).


Chessboard and chess piece recognition with the support of neural networks

3. S. Kolkur1, D. Kalbande2, P. Shimpi2, C. Bapat2, and J. Jatakia2. (2017).


Human Skin Detection Using RGB, HSV and YCbCr Color Models. Published
by Atlantis Press.

4. Gaurav Jain. (2010). Detects skin by producing a map of "skin-like" pixels


within a given image. Retrieved at
https://www.mathworks.com/matlabcentral/fileexchange/28565-skin-
detection. (2018).

5. Python-chess library.
https://python-chess.readthedocs.io/en/latest/index.html

6. Flask framework in python.


http://flask.pocoo.org/

7. Flask socketIO service.


https://flask-socketio.readthedocs.io/en/latest/

8. Stockfish 10 – open source chess engine.


https://stockfishchess.org/

9. UCI - Universal Chess Interface.


https://en.wikipedia.org/wiki/Universal_Chess_Interface

10. Python 3.7.0.


https://www.python.org/downloads/release/python-370/

11. Vision function – detectcheckboardPoints in MATLAB,


https://www.mathworks.com/help/vision/ref/detectcheckerboardpoints.html

12. Geiger, A., F. Moosmann, O. Car, and B. Schuster. "Automatic Camera and
Range Sensor Calibration using a Single Shot," International Conference on
Robotics and Automation (ICRA), St. Paul, USA, 2012.

62
13. Speeded up robust features. Wikipedia
https://en.wikipedia.org/wiki/Speeded_up_robust_features

14. MATLAB-Image Category Classification Using Bag of Features.


https://www.mathworks.com/help/vision/examples/image-category-
classification-using-bag-of-features.html

15. MATLAB-Image Category Classification Using Deep Learning.


https://www.mathworks.com/help/vision/examples/image-category-
classification-using-deep-learning.html

16. Support-vector machine. Wikipedia.


https://en.wikipedia.org/wiki/Support-vector_machine

63

You might also like