I am in the process of creating a program that gets input images of pictures of dices, and it has to tell the value of the throw. In other words, the sum of the points on the top sides of the dices. For example, this is one of my example images:
For this, I would like to receive the number 4 as the result.
Here is what I have accomplished so far:
- Segmenting the individual dices. This step is working quite well.
- Identifying each point on the individual dices. This is working okay, could be better.
- Group the points on a dice, based on what side they are on. I'm stuck here. From this it would be easy to find the top side and thus the value of the throw.
For example, I tried to group the points with K-means algorithm, but it groups points together that are not on the same side, very often. Here is what the picture looks like after finding the points (marked with blue) and running K-means (group center points marked with green):
Besides K-means I tried another clustering algorithm, also with no success (this was a hierarchical clustering). I have also checked this question, which is about the same problem basically. However, the answers are only applicable to the image OP posted, and cannot be at all generalized.
I'm asking how I could group the points marked with blue dots, based on which side of the dice they are on. I'd love to group them something like this:
Not for this one image, I have a great many of other similar images of dices, some of the from different angles, so methods that use point circularity or size won't really work. Thank you for any help.