Chess Playing AI

Developed an interface of playing chess using Stockfish engine and Computer Vision in real world. Human vs AI (Stockfish engine).

Camera captures the image of chessboard then the image is analyzed using imageprocessing to identify the moves made by opponent and stockfish engine calculates the best possible move.

opencv python

Youtube Video

check out my youtube video

Method of Working

Step - 1

Image1 : Image of Chess Board befor player move piece|Image2 : Image of Chess Board after player move piece

|

Step - 2

Difference of image by using function absdiff in CV2 Change Difference_image to Gray scale image
diff = cv2.absdiff(image1,image2) diff_gray = cv2.cvtColor(diff,cv2.COLOR_BGR2GRAY)

Step - 3

Apply thresholding on Grayscale image Find Contours on threshold image
matrix,thresold = cv2.threshold(diff_gray,value,255,cv2.THRESH_BINARY) cnts,_ = cv2.findContours(thresold, cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)