All Projects → bagaturchess → ChessBoardScanner

bagaturchess / ChessBoardScanner

Licence: GPL-2.0 license
Java based Chess Board Scanner, which converts 2D chess board image into a machine readable format a.k.a. Forsyth–Edwards Notation (FEN). It uses OpenCV and Deeplearning4j frameworks, complemented with some proprietary algorithms implemented for realizing the goal. It currently supports the chess board and pieces sets of the most common online c…

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to ChessBoardScanner

stockfish-chess-web-gui
Responsive chess web GUI to play against the Stockfish 10 chess engine. Multiple web GUI implementations have also been included.
Stars: ✭ 21 (-34.37%)
Mutual labels:  chess, chessboard, chess-board
Online-Chess
A chess website where people can play against each other online.
Stars: ✭ 28 (-12.5%)
Mutual labels:  chess, chessboard
FDChessboardView
An iOS / Mac view controller for chess boards
Stars: ✭ 75 (+134.38%)
Mutual labels:  chess, chessboard
chessboard-recognizer
Uses neural networks to extract chess positions from images
Stars: ✭ 59 (+84.38%)
Mutual labels:  chess, chessboard
ChessLib
C# chess library containing a complete data structure and move generation.
Stars: ✭ 37 (+15.63%)
Mutual labels:  chess, chessboard
Image-Classification
Pre-trained VGG-Net Model for image classification using tensorflow
Stars: ✭ 29 (-9.37%)
Mutual labels:  image-recognition
bevy chess
Chess demo in Bevy
Stars: ✭ 59 (+84.38%)
Mutual labels:  chess
sharpmask
TensorFlow implementation of DeepMask and SharpMask
Stars: ✭ 31 (-3.12%)
Mutual labels:  image-recognition
Chess.NET
[No longer maintained] A .NET chess library, written in C#
Stars: ✭ 48 (+50%)
Mutual labels:  chess
ChineseChessOL
Online Heads-Up version of Chinese Chess built with Unity 3D
Stars: ✭ 15 (-53.12%)
Mutual labels:  chess
kokopu
A JavaScript/TypeScript library implementing the chess game rules and providing tools to read/write the standard chess file formats.
Stars: ✭ 18 (-43.75%)
Mutual labels:  chess
shogi-pieces
Shogi (Japanese Chess) pieces and boards
Stars: ✭ 25 (-21.87%)
Mutual labels:  chess
visualsearch
Visual Search is a little app to find and cluster similar images using Tagbox
Stars: ✭ 31 (-3.12%)
Mutual labels:  image-recognition
image space
Interactive Image similarity and Visual Search and Retrieval application
Stars: ✭ 91 (+184.38%)
Mutual labels:  image-recognition
LIT
[AAAI 2022] This is the official PyTorch implementation of "Less is More: Pay Less Attention in Vision Transformers"
Stars: ✭ 79 (+146.88%)
Mutual labels:  image-recognition
ARKitImageRecognition
ARKit 1.5 - Image Recognition Demo
Stars: ✭ 34 (+6.25%)
Mutual labels:  image-recognition
fastchess
Predicts the best chess move with 27.5% accuracy by a single matrix multiplication
Stars: ✭ 75 (+134.38%)
Mutual labels:  chess
ymir-js
This toolkit is created to make it easier for you to develop games like chess, checkers, go, match 3 puzzle and more. It is still under development.
Stars: ✭ 30 (-6.25%)
Mutual labels:  chess
chess-openings
An aggregated data set of chess opening names
Stars: ✭ 223 (+596.88%)
Mutual labels:  chess
ImageRetrieval
Content Based Image Retrieval Techniques (e.g. knn, svm using MatLab GUI)
Stars: ✭ 51 (+59.38%)
Mutual labels:  image-recognition

License

The license is GPL-2.0-only

Overview

This project aims to demonstrate how to extract the chess position in a machine readable format called Forsyth–Edwards Notation (FEN) having the 2D picture of the board. At the moment it supports 4 chess sets: default chess sets from chess.com, lichess.org and chess24.com as well as a few sets from paper chess book. Of course, the architecture is extensible and different chess sets could be added additionally.

Advanced technologies solve complex problems

  • Computer Vision (CV) subdomain of Artificial Intelligence: It uses OpenCV as a computer vision library or framework, which helps in extracting the chess board from the image and transforming it to ideal square.
  • Machine Learning (ML) subdomain of Artificial Intelligence: Both libraries or frameworks Deep Netts Community Edition and Deeplearning4j frameworks as a basis for convolutional nueral networks for chess board classification and chess pieces recognition. It uses both ML frameworks in order to demonstrate how to integrate your code with both, but the code works well with them separately as well.

Credits

This project would not be possible without:

Directions for further development

  • Extend the solution to work with chess diagrams drawn on paper, this will save a lot of positions from old books in computer format.
  • Add support for additional popular online chess sites, which can be recognized by the program.
  • Improve board corners detection, besides the currently used algorithms: findChessBoardCorners by build-in function, findChessBoardCorners by Hough lines and findChessBoardCorners by contours.

If you would like to contribute to the project, do not hesitate to contact me.

Android Application

The code is used productively by this app, which could be found here: https://metatransapps.com/chess-board-scanner-and-analyzer/

Technical details

If you need technical explanation of the algorithms used, please check this YoutTube video

Running the program

The project structure is an eclipse based project, which can be directly imported into the Eclipse IDE. All necessary libraries for Deep Netts and Deeplearning4j are included into the libs folder, but you need to add the OpenCV library version 4.5.1 (java and native parts) and refer them from the project as described here: https://opencv-java-tutorials.readthedocs.io/en/latest/01-installing-opencv-for-java.html The basic main classes are in bagaturchess.scanner root package.

How to create a Dataset for the CNN training

  • Obtain an image of the initial board, which contains all chess pieces for both sides/colors.
  • Add raw image of the initial board, containing all pieces to input directory of your choise. let's say".\res\books_set_2_input1.png".
  • Than crop the image (transform the chess board to ideal square) by using bagaturchess.scanner.RecognitionMain_DeepNetts main class. First, set CROP_BOARD_FROM_IMAGE to true and start main function. Than checked if the cropped board "./data/OpenCV_board_croped.png" is correctly cropped. If yes, than go to next step, otherwise try with another image.
  • Copy cropped board image inside ".\res\cnn\books\setXYZ\input2.png"
  • In bagaturchess.scanner.machinelearning.dataset.DatasetGenerator_ByBoardImage, add the input png (example: ".\res\cnn\books\setXYZ\input1.png") to the INPUT_FILES array.
  • Set OUTPUT_DIR to the directory, where the pieces’ images will be generated (let’s say "./datasets_deepnetts/dataset_books_set_2_extended/") and run the main function in this class for the generation process itself. It will take around 10 seconds.
  • Add labels.txt file in the output directory with this content: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12. Separate the numbers by new lines instead of by comma.
  • Run deepnettsplatform64.exe and import output directory. DeepNettsPlatform UI will create index.txt file in the same directory.
  • Now you have a DataSet and we are ready for training CNN for this chess pieces set with DeepNetts.

How to Train the CNN and give it a try

  • You could train the CNN by using the bagaturchess.scanner.machinelearning.learning.impl_deepnetts.ScannerLearning_Edition_Community12 class.
  • Run it and wait the training to achieve accuracy equal to 1 or max 50 iterations (which happens first). Stop the training and now we have the CNN file, Let’s say dnet_books_set_2_extended.dnet. Normally this takes up to 5 minutes on laptop/computer.
  • Now let’s try it.
  • You could run it by using the main function inside the bagaturchess.scanner.RecognitionMain_DeepNetts class.
  • First we add in the code our new CNN file, like netsNames.add("dnet_books_set_2_extended.dnet"); and then run it ...
  • Good luck!

Do you like the project?

You could give it a star by clicking 'Star' button placed top-right of the page. This will rank better the project and will allow other people to easily find it out on github.

Author

The author of the project is Krasimir Topchiyski.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].