Yolo Segmentation Chess

Project Flow
  • ♔♕♗♘♙♚♛♝♞♟♖♜

  • The camera captures the image of chessboard then the image is analyzed using image processing to identify the moves made by an opponent and stockfish engine calculates the best possible move.

Method of Working

Step - 1

Image Transformation

transform

Example

Input-Frame
Predicted-Mask
inference-border-image
warp-perspective-Image
Yolo-Inference-Image
Input-Frame -> Predicted Mask -> Corner Points -> Warp Perspective Image-> Yolo Inference Image
Input-Frame
Predicted-Mask
inference-border-image
warp-perspective-Image
Yolo-Inference-Image
  • With help of unet model mask chess board and detect chess baord corner points with help of opencv operations. and apply warp perspective transformation on it.
Input-Frame warp-perspective locate-boxes
Input-Frame
warp-perspective
locate-boxes

Step - 2

Image1 : Image of Chess Board befor player move piece Image2 : Image of Chess Board after player move piece
“2”
“3”

step - 3

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)
“2”
“3”

step - 4

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)
“Threshold_image”
“show_Contours”