r/opencv • u/RoyRoyKing • Jan 22 '22
Question [Question] Detection of custom BackGammon board
Hello everybody, I am a high-school student for electronics and for my final project I paired up with a friend and we decided to build a BackGammon board that can play against you physically. In that I mean that the board will be able to detect a player movement, and physically make his own move in response.
For those of you that don't know what backgammon is: https://en.wikipedia.org/wiki/Backgammon
the board detection is performed by an overhead camera connected to a Raspberry Pi board, running an openCV python script for detecting the location of the board and the game pieces. Now while I have been coding for a few years, I have never used openCV or even python for any project, so I am definitely a beginner in the computer vision field.
I have been working on this part of the project for about 4 days and have encountered more problems than a trunkless elephant. I believe I have a good grip on the language and the library by now, but I had problems with every method I've tried.
I tried rectangle contour detection, which worked but very inconsistently. I am also making the pysical board so I have tried drawing green circles on the corners and using an hsv filter in combination with the Hough circles method which lead me into a whole new array of problems that I will happily rant about if you'll ask for that information.
Basically what I'm asking is how you'd suggest I go about detecting the board and game pieces location in the code, and how I should make my board (because the one I built was just a prototype and not the final version) and the game pieces (because I'm 3d printing them too). should I add custom indicators, is there a trick for detecting board games I'm unaware of?
Thank you in advance for any help, and I will share any additional information you ask for in the comments, I just didn't want to bombard the post with information.
1
u/aschelch Jan 28 '22
Hi,
For your problem, I would go with multiple HSV filtering and contour detection as you started.
Here is what I would try :
Detect the full bord a use it as a ROI (Region Of Interest for pieces detection)
Make a wrap perspective to do a bird view of the board
Detect pieces
Detect triangles (if necessary)
Use pieces contours coordinates
Here is an example of piece detection i did in 30sec on Seevi.app : https://imgur.com/gallery/JtagQ8G
If you can build your own board, I would maybe use a different color for each "component" you want to detect to make it easier. (2 types of pieces, and the 2 types of triangles)
Good luck!