r/programmingrequests • u/GoatPlaysGames • Apr 07 '21
Automated Chess Notation via phone/tablet
Hello everyone and thank you for your time.
I am looking to see if someone could make an Android app that allows you to take a video using the device's camera, recording a physical chess board, and putting each move into chess notation.
I don't know if this is possible, but my friends and I are going to be hosting a blitz tournament and we don't want to have to take time write the notations while playing, and we just think this would be cool.
3
Upvotes
1
u/POGtastic Apr 09 '21
I might tackle this for gits and shiggles. I'm thinking of something like the following:
Use basic OpenCV corner-detection and contour-detection algorithms to find the chessboard in the picture. I'll make the assumption that the camera is mostly vertical and looking down, and has the white pieces at the bottom of the image.
It's likely that the pieces will not be recognizable by the device - we're looking at it top down, after all. So instead of being "rook, knight, bishop, etc," the best that the program can do is to find the position of black pieces and white pieces.
However, we know the rules of chess, we know the starting configuration, and we know whose turn it is.
We determine whether a move has occurred by running this
pieceDetectalgorithm on successive frames and seeing if any pieces have changed position. If that constitutes a legal move, we can update the board configuration and record the move. The program needs to be robust enough to discard weird stuff, (arms in the way of the image, a piece currently being moved, etc) so it'll need to maintain a data structure of moves that can be undone if it's clear that it misjudged a position the first time.It ain't going to be implemented any time soon, (wife, kid, job, coursework, have to learn more Android, etc) but this is an interesting problem, and I can probably do it.