'Recommended pattern recognition technique for chess board
I'm trying to do an application which, among other things, is able to recognize chess positions on a computer screen from screenshots. I have very limited experience with image processing techniques and don't wish to invest a great amount of time in studying this, as this is just a pet project of mine.
Can anyone recommend me one or more image processing techniques that would yield me a good result?
The conditions are:
- The image is always crispy clean, no noise, poor light conditions etc (since it's a screenshot)
- I'm expecting a very low impact on computer performance while doing 1 image / second
- I've thought of two modes to start the process:
- Feed the piece shapes to the program (so that it knows what a queen, king etc. looks like)
- just feed the program an initial image which contains the startup position, from which the program can (after it recognizes the position of the board) pick each chess piece
- The process should be relatively easy to understand, as I don't have a very good grasp of image processing techniques (yet)
- I'm not interested in using any specific technology, so technology-agnostic documentation would be ideal (C/C++, C#, Java examples would also be fine).
Thanks for taking the time to read this, and I hope to get some good answers.
Solution 1:[1]
It' an interesting problem, but you need to specify a lot more than in your original question in order to find an acceptable answer.
On the input images: "screenshots" is quote vague a category. Can you assume that the chessboard will always be entirely in view? Will you have multiple views of the same board? Can you assume that no pieces will be partially or completely occluded in all views?
On the imaged objects and the capture system: will the same chessboard and pieces be used, under very similar illumination? Will the same lens/camera/digitization pipeline be used?
Solution 2:[2]
Salut Andrei,
I have done a coin counting algorithm from a picture so the process should be helpful. The algorithm is called Generalized Hough transform
- Make the picture black and white, it is easier that way
- Take the image from 1 piece and "slide it over the screenshot"
- For each cell you calculate the nr of common pixel in the 2 images
- Where you have the largest number there you have the piece
Hope this helps.
Solution 3:[3]
Yeah go with Salut Andrei,
- Convert the picture into greyscale
- Slice into 64 squares and store in array
- Using Mat lab can identify the pieces easily
- Color can be obtained from Calculating the percentage of No. dot pixels(black pixels) threshold=no.black pixels /no. of black pixels + no. of white pixels, If ur value is above threshold then WHITE else BLACK
Solution 4:[4]
I'm working on a similar project in c# finding which piece is which isn't the hard part for me. First step is to find a rectangle that shows just the board and cuts everything else out. I first hard-coded it to search for the colors of the squares but would like to make it more robust and reliable regardless of the color scheme. Trying to make it find squares of pixels that match within a certain threshold and extrapolate the board location from that.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Francesco Callari |
Solution 2 | andrei c |
Solution 3 | user1866956 |
Solution 4 | Sean Tublewicz |