How can i recognise Chess figure and put them correctly in the center of each square

Hi guys,
I am working on a project that allows me to play chess with a robotic arm.
I want to know if it’s possibile to solve the following problems with OpenCV:

Find the center-point of a chess-figure (The robot must place the chess piece in the centre of each square)
determine the alignment of the horse, because the horse can be be only griped in a certain direction.
If yes can you pleasure help me or give me some ideas ?
Thank you

First idea that comes to my head: use a RGB-D camera (like Intel RealSense) to get a 3D point cloud of the chessboard and the pieces. This will simplify the task a lot - like elimination of parallax effect, correct height of each piece etc.

The PCL library is probably better in processing the point clouds. Try a template matching to recognize the pieces.

do you have maybe an exemple ? because I am a beginner.
thank you

do you have a video or a picture that can hep me ?

No. I don’t have a chessboard. And I don’t have a chess-playing robot neither.

Take care, this is an advanced project. So be prepared to learn and work a lot to make this work. There is no magic robot.playChess() function or 10 minute youtube video with the solution.

Hi @Atef08 ,

Two very different videos showing two very different approaches:

But if you are willing to learn, if you can explore the idea from the first video, you should look for opencv tutorials about contours and moments.

The second video uses a deep learning model, you can follow the links to the github project and learn how to use it and how to train it.

I don’t believe this is doable by a beginner - but I can be wrong. I don’t believe anyone here will guide you in this project from scratch.

I recommend you choose and approach and come back to ask specific questions about opencv functions.

thank you :slight_smile:
i have a question if we can find the corners of each square so how can we find the centre of this square ? because the robot arm need to put the chess figures exacty in the centre .
thank you


You can take a look at OpenCV: Camera calibration and 3D reconstruction (calib3d module)