topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Sunday October 13, 2024, 8:50 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: Dice analyzer machine project  (Read 59820 times)

Stoic Joker

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 6,646
    • View Profile
    • Donate to Member
Re: Dice analyzer machine project
« Reply #25 on: January 24, 2016, 01:34 PM »
Camera looking down vs camera from underneath

Given the frequent use of 8 sided dice in you screen shots, I was thinking camera from the bottom using lightly smoked glass might make the extra non-relevant - yet visible - faces easier to ignore.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,913
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #26 on: January 24, 2016, 01:37 PM »
i definitely need to experiment with camera from bottom facing up.

in fact i was wondering if it wouldnt be possible to use some kind of closing aperature ring on top surface that would simultaneously center the die AND block out all but the bottom-facing die face.. though that seems a bit far fetched.
« Last Edit: January 24, 2016, 02:02 PM by mouser »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,913
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #27 on: January 24, 2016, 04:05 PM »
I was thinking camera from the bottom using lightly smoked glass might make the extra non-relevant - yet visible - faces easier to ignore.

i don't know enough about optics, but maybe someone who does could shed some light on the question of whether it's possible to create a glass "surface" (lens?) that had the effect of making something the details of an object laying flat against it very clear, but rapidly blurring anything that was even a couple of millimeters away...

to some extent, some of the privacy films you can put on glass has an effect in the same vein -- but this would have much more precise requirements..

Jibz

  • Developer
  • Joined in 2005
  • ***
  • Posts: 1,187
    • View Profile
    • Donate to Member
Re: Dice analyzer machine project
« Reply #28 on: January 25, 2016, 12:54 AM »
My first thought was aperture as well. If you have the camera below the floor, all die will have the same distance to the camera, and you can use the aperture to make only a very narrow area in focus. I don't know how easy lenses capable of this at short distances are to come by, perhaps a macro lens.

Stoic Joker

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 6,646
    • View Profile
    • Donate to Member
Re: Dice analyzer machine project
« Reply #29 on: January 25, 2016, 06:52 AM »
QuoteI was thinking camera from the bottom using lightly smoked glass might make the extra non-relevant - yet visible - faces easier to ignore.i don't know enough about optics, but maybe someone who does could shed some light on the question of whether it's possible to create a glass "surface" (lens?) that had the effect of making something the details of an object laying flat against it very clear, but rapidly blurring anything that was even a couple of millimeters away...

It's been a while since I worked in optical - like over a decade... But if you have an (eyeglass) optical surfacing lab in your area. You should be able to get them to surface a custom CR39 (very high grade plastic) lens for you. The blanks are (IIRC) ~3" in diameter before they are cut down into the eyeglass frames - so there's a good bit of material to work with.

The object here is to get the (camera facing base curve as close to 0 as possible so the back side can be slightly cupped - say a 2-ish diopter curve. this will help to gently coax the die to land in the center...and push anything outside the directly contacting surfaces out of focus helping to blur/hide it. Also the use of a polaroid (sunglass lens) might make it an even better hide for the edges ... and/or just help hide the camera/look cool.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,913
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #30 on: January 25, 2016, 10:39 AM »
So one difficulty with having the camera on the BOTTOM facing up, is figuring out a mechanism to roll/tumble the die that would still allow it to sit flat on the nice clear glass at the bottom.

Stoic Joker

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 6,646
    • View Profile
    • Donate to Member
Re: Dice analyzer machine project
« Reply #31 on: January 25, 2016, 11:18 AM »
The unsurfaced CR39 lens blanks are almost an inch thick to start with, so you can pretty much pick what you want for thickness to screw into or glue onto. Actually I was thinking - Steampunk - go with the cup style roller from your video, get the edge of the lens beveled, and use an eyeglass frame style mount to put the lens in the bottom of the - lightly polished/brushed brass - cup. :D

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,913
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #32 on: January 25, 2016, 11:38 AM »
one thing we have to consider is that the sharp cornered dice are going to be bouncing around on their containers really hard, over and over and over, thousands of times.. another argument against having camera facing up through a glass surface that the dice are going to be scratching against..

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,913
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #33 on: January 25, 2016, 12:04 PM »
Clearly I need a clever engineer to take on the hardware half of this.. Anyone up for it? With a prototype we could kickstart it :)

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,913
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #34 on: January 25, 2016, 12:07 PM »
I have one of these cheap $10 dicer roller toys on order -- if it can be modified it's hard to imagine a cheaper solution:
http://www.amazon.co...wered/dp/B0079RKBGK/

Screenshot - 1_25_2016 , 12_07_17 PM.png

I believe the basic mechanism is that the bottom SPINS, and friction causes the dice to tumble around.

Stoic Joker

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 6,646
    • View Profile
    • Donate to Member
Re: Dice analyzer machine project
« Reply #35 on: January 25, 2016, 12:08 PM »
Plastic dice aren't that heavy...so as long as the dice aren't made of metal or glass, the CR39 lens/base should hold up just fine. I've worn glasses for years, and they're surprisingly hard to scratch.

Stoic Joker

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 6,646
    • View Profile
    • Donate to Member
Re: Dice analyzer machine project
« Reply #36 on: January 25, 2016, 12:57 PM »
Or for a controlled impact bottom camera type configuration:

11705773_1_l.jpg

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,913
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #37 on: January 25, 2016, 12:59 PM »
yeah something like that could work, driven by a motor.
Especially if the bottom funneled the (single) die down to a smaller more predictable area. having a smaller (say 1-2 inch diameter) bottom area (think of a CUP shape or upside-down cone), it would be able to rest closer to bottom of base.

That does seem to offer a fairly reliable way of shaking up the die too.

Stoic Joker

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 6,646
    • View Profile
    • Donate to Member
Re: Dice analyzer machine project
« Reply #38 on: January 25, 2016, 01:13 PM »
Especially if the bottom funneled the (single) die down to a smaller more predictable area. having a smaller (say 1-2 inch diameter) bottom area (think of a CUP shape or upside-down cone), it would be able to rest closer to bottom of base.

A 2-4 diopter curve (assuming the front is 0/1) should make for a sufficient "cup". ;)

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,913
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #39 on: January 25, 2016, 01:17 PM »
Well there's no reason that the lens curve has to be the entire "cup".. the lens could simply be the BOTTOM of a more pronounced and sharper dimple in the bottom of the container that spins.

Think of the spinner as being formed from two of these, where the bottom of the cup is the lens, and the two cups are attached at their wider mouths.
plastic-cup-drawing-356949-2.jpg


And of course there is no reason the container has to be symmetrical.  you could have the sharp-sloped cup on one and and more of a half-sphere on the other (like an ice cream cone) -- whatever would better tumble the die.  The key thing is that when the cup end comes to rest, it constrain the die to a very narrow region on the base.  That has 2 advantages: First, it centers it above camera more narrowly, and second, it means less clearance distance needed so the bottom of the cup can be closer to camera.
« Last Edit: January 25, 2016, 01:22 PM by mouser »

Stoic Joker

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 6,646
    • View Profile
    • Donate to Member
Re: Dice analyzer machine project
« Reply #40 on: January 25, 2016, 03:56 PM »
Yes, I phrased that badly...but I'm at work/rushing a bit.. :D

The intent was - as you stated - for it to be the bottom of something (I like the bird cage look in the pic), and it's curvature would/should center the die for the camera (theory..).

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,913
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #41 on: January 26, 2016, 07:25 PM »
A screenshot showing results of a very quick test of unsupervised clustering.

In this case the system took 17 photos and was told that it was taking a picture of a 6 sided die. It then grouped the 17 photos into 6 clusters most similar to each other.
(There was no stage of training telling it what each side of the die looks like).

clusteringdice.png



This gives you a sense of how the procedure would work for testing a die for fairness.  User would insert a die and specify how many unique faces the die has (N).  The system would then start rolling the die taking photos, eventually clustering the images into N clusters, and then computing statistics on the frequency and patterns of seeing cluster.


mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,913
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #42 on: January 26, 2016, 07:32 PM »
What happens if you lie to it and tell it the wrong # of die faces?  Glad you asked.

Mistakenly telling it there are 5 unique die faces (2s and 3s look like they are similar enough):
dieb2.png


Mistakenly telling it there are 7 unique die faces (hey those two 1s look like different faces):
dieb1.png


Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Points: 1
  • Posts: 9,759
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #43 on: January 27, 2016, 12:31 AM »
A screenshot showing results of a very quick test of unsupervised clustering.

[ Invalid Attachment ]

I'm embarrassed to admit that I was staring at the white circles in each of these pictures thinking each circle was a separate die, and I was rather bewildered at how I couldn't tell any of them apart! :-[

Stoic Joker

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 6,646
    • View Profile
    • Donate to Member
Re: Dice analyzer machine project
« Reply #44 on: January 27, 2016, 06:28 AM »
I'm embarrassed to admit that I was staring at the white circles in each of these pictures thinking each circle was a separate die, and I was rather bewildered at how I couldn't tell any of them apart!

(You are not alone..) That one threw me for a minute too. I had to scroll down a bit to recognize the pattern.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,913
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #45 on: January 28, 2016, 12:14 PM »
I clearly need help with the hardware design and manufacturer.. any engineers here willing to give it a try?

Let me summarize the basic kinds of approaches we've discussed:

  • Camera on bottom looking up, with a tumbling/rolling container above. Notes: We don't know how far away the cheap raspberry pi camera will have to be to focus. We don't know how hard it will be to ignore background when facing up and looking at the sky (as opposed to looking down on a single color base).  There needs to be an easy way to insert and remove dice.
  • Camera above a container that spins to tumble (think a die bouncing on a roulette wheel).
  • Camera above a container that is "tapped" in different places from below to bounce die around.

Any other options?

To summarize the technical goals:

  • Good lighting so the camera doesn't see shadows, and has a predictable background behind dice.
  • Simple to ensure reliability with tens of thousands of die rolls.
  • Reasonably cheap/easy to build (i suppose this is least of our concerns).
  • Easy to add/remove dice.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,913
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #46 on: February 03, 2016, 11:20 AM »
I've decided to write up a little paper on the project, if for no other reason than to get it out of my system and remember the important parts so i can come back to it when i find someone willing to do the hardware -- and i guess i'll open source the code while i'm at it.  I'll upload both when i get a first draft of the paper done.

I'm still interested in matching up with someone who might be interested in creating the hardware (maybe as an advanced school project?).

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,913
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #47 on: February 05, 2016, 01:46 PM »
So, the $10 dice rolling machine ordered from amazon arrived today, made in china, shipped from germany (i will never understand the economics of this stuff).

At first glance it seems to work pretty well at creating a random die roll.

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Points: 1
  • Posts: 9,759
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #48 on: February 05, 2016, 02:55 PM »
So, the $10 dice rolling machine ordered from amazon arrived today, made in china, shipped from germany (i will never understand the economics of this stuff).

Agreed. I can buy something from a website for $0.80 and get it shipped from China with no additional shipping costs/fees.

How is that even possible? :huh:

I suppose maybe the gizmo for $0.80 only costs $0.02 to produce (in mass quantities) so they make quite a large margin of profit to pay for shipping, etc.?

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,913
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #49 on: February 06, 2016, 09:49 PM »
Considering beaglebone instead of raspberry pi..

Though i do like the easy availability of camera and touchscreen for the raspberry pi, so i think probably that's still the best way to go.
« Last Edit: February 06, 2016, 10:29 PM by mouser »