Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Capture real time images of chess games and convert them to into FEN strings for stockfish analysis

License

Notifications You must be signed in to change notification settings

mlitton10/piChess

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

piChess

Capture real time images of chess games and convert them to into FEN strings for stockfish analysis

A good paper: https://mdpi-res.com/d_attachment/jimaging/jimaging-07-00094/article_deploy/jimaging-07-00094-v2.pdf?version=1622796868

There is a major problem evident in this paper: See page 14 figure 12 Mean inference time on CPU: 2.11 +- 0.64 s Mean inference time on GPU: 0.35 +- 0.06 s The CPU inference time is slow, and we can assume that the rpi4 will be even slower. The CPU used was a 3.20 GHz Intel Core i5-6500 CPU. Rpi is not this good. Most of this time is taken up by the piece classification CNN.

Current State:

  1. Start with image of chess board: alt text

  2. Use Canny edge detection to find true edges. This finds the edges in the image but they are 'wobbly' and also don't extend all the way to the end of the image which could be useful for cropping. alt text

  3. To improve this I used statistical methods to find the pixel locations where the edges occured and created an image of these edges extended through the whole image. Again, this could be useful for cropping and defining board coordinate systems. It also may be helpful for removing the extraneous stuff like the row/column letter number labels. This is NOT a Hough transform but achieves a very similiar end result. alt text

Methodology: First we find the average gray scale pixel value in each row and column of the image: equation equation

The overall mean pixel value of the image: equation

And the standard deviations of rows and columns: equation equation

We consider a row/column to be an edge if the following condition is true: equation equation

  1. We can overlay this new grid ontop of the original image: alt text

  2. Next, we can use this grid to find corners in the image using some algorithm. I tried out Harris Corner detection for now but there are a few options alt text

6.Finally, we can overlay these corners onto the original image: alt text

The above methodology will fail for skewed images or images where the board is rotated in frame. The failure occurs at step 3 since the statistical analysis assumes the camera is top down view. The error will scale with rotation angle or skew. Example of this effect:

We can fix this problem by using a Hough transform instead.

About

Capture real time images of chess games and convert them to into FEN strings for stockfish analysis

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages