-
Notifications
You must be signed in to change notification settings - Fork 31
Description
The current chess piece recognition implementation is highly accurate, but I find it's still not accurate enough for automation under some conditions. I've observed two problems:
-
False recognition, such as detecting a knight as a pawn. The result is a non-updating chess board, because all the moves after this point will be treated as illegal. This problem is more pronounced when playing as black using a black-and-white chessboard due to lower image contrast.
-
Marginal recognition. with a stationary chess board, some chess piece have marginal recognition that rapidly oscillating between two candidates.
In principle, by making the algorithm stateful using the result of the previous moves, it's possible to filter obvious false results out of the raw image inference data. For example:
- If a non-captured piece has suddenly disappeared from the board, the output of a chess engine can be used to check all the possible new locations of this piece, if the destination square has suddenly been occupied by a new piece, this is the almost always the location where false detection has occurred. The false candidate can thus be removed from the raw inference result, and the 2nd or 3rd candidates in the raw inference list would likely be the correct one.
- The sudden appearance of an already-captured piece is almost always a false detection (unless it's a promotion), so it should be excluded from the candidate list of the raw inference results.
- The identity of an unplayed piece should remain as is.
However, this problem is complicated by the possibility of an illegal move, a takeback, or a takeback followed by an illegal move. Ghost moves may appear if it's not handled with care. A similar problem exists if two capture moves are made in a rapid succession.