Page 1 of 1

Dice testing, Part 2

PostPosted: January 9th, 2021, 2:06 pm
by Anderas
Some of you might still remember that I asked for help in developing a die test.

Image

Basically, what came out was: I roll it 150 times, I do some statistics, then I decide that it is "OK" or not.

Well, I decided to go to version 2.


Image
Image
Image

... first test...


Box around it
Image

Axis through
Image

Raspberry Pi 3 with Pi Camera 2
Image

Pi cam and Pi and motor fixed to the tower
Image

I added a lamp and a reed sensor to stop it in the right place.
Now I can insert a die and it will roll it like, 160 times.


It takes a photo each time, and one photo without die.
After all, if I take the photo without die and I substract it from the photo with die, only the die should stay right?
Well, it wasn't exactly that easy; but the principle was right.
Those images are transferred via SSH to my big computer. That one is then searching the die, cuts it out and tries to read the number.

Image
Yes, reading this is not easy. Sometimes the pips are bright as a sun, sometimes they are near invisible. OpenCV wasn't up to the job in 30% of the cases; statistics couldn't do the job in 20% other cases (but 20% different from the openCV difficulties)... KMeans couldn't do the job in 15% of the cases... again 15 different per cent from the other two. Of course I could just use all three methods and add the results, it would be a 98% fit. But then it would calculate more than a second per die, which seems awkward.

So I gave in and trained a neural net instead. That's kind of cheating because it means I don't solve the problem. Also, since two weeks my computer is training on a couple of die images and it still confuses a :roll1: with a :roll2: sometimes.
But: It works now, with just about 2%-3% errors. On this image, they are marked with their respective numbers. Click on it, you can try and find the one error in this picture collection.

Image

I tested the Heroquest movement dice with it.
My suspicion came true! One of them strongly prefers to roll a 1, the other of the two strongly prefers the 3. Yes! I knew it! It was worth the work! :lol:
The third one, the one who was giving his images to this forum post prefers the 2, by the way

Image

Two months of development and I can get a result quickly now! :-)

I will upload my dataset on kaggle sometime soon, and my code on git hub. But today, I keep training it.

Image

Re: Dice testing, Part 2

PostPosted: January 10th, 2021, 5:00 am
by lestodante
WOW!!! AMAZING JOB!!!!
Am I wrong or number 3 is the less common result?

Re: Dice testing, Part 2

PostPosted: January 10th, 2021, 6:24 am
by Anderas
Yes, on this die the 2 was too often, and the 4 too rare.
The index starts at 0 and is annoying the eye in the result table. :-)