Webcam object recognition-dice?
Moderator: Moderators
-
biscuit495
- Posts: 2
- Joined: Sat Oct 09, 2010 9:36 am
Webcam object recognition-dice?
I am trying to get a web cam to recognize the sides of a die. The web cam will be under Plexiglas looking at the underside of the die. I need software that can identify the side by looking at the number of black dots that are facing it. I have looked around at some object recognition software but I have not found anything where the user can define the objects and then the camera can recognize them in real time. I think this is easily doable since web cams can recognize QR codes and a die is much simpler. It would be good if the software could output the number rolled to a text file or some sort of database. I am not a programmer so I do not know how to even begin writing software that could do this. If I could find some source code for a similar project I may be able to modify it but it would be nice if I could define the objects inside of the program. Does anyone know of software that can do this? Maybe based on Adobe Air? Thanks for your help!
Re: Webcam object recognition-dice?
You don't need to define the object as a whole, only sides.
All dice rest on flat sides. Each side is unique. The number 'up' when a given side is 'down' is unique.
So a table of what side 'down' means what side is 'up' could be used to solve this problem.
It should be possible to reconise using PoTrace or other similar raytracing program and (high contrast) dice what side the camera is looking at.
With common six sided dice it would find the edge of the dice, then count the dots (of certain volume) and look up in the table what number is 'up'. This would work with all six sided dice, including sphere cuts ones (which I favor despite the marked decrease in randomness).
With 'irregular' flat faced 4,8,10,12, 20 and 100 sided dice this gets slightly more complicated. While all of these have sides which are generally strait edged, they use numerals.
The software can 'learn' the dice by recording images of each side, and then straitening them out.
when rolled the outline of the dice is read to determine what type of dice it is (edges of dice, edges of face). Then this image is rotated level with each of the sides of the face, and compated to the table of this dice type for a best match.
With 'irregular' curved faced dice (3 and 5) the image is leveled with the furtest two points of the dice, not the face, since that will appear to be is gradient.
I would start with the python modules used with the multitouch since that is the only software that I've personally played with; however there may be other good (open source) options that I am ignorant of.
All dice rest on flat sides. Each side is unique. The number 'up' when a given side is 'down' is unique.
So a table of what side 'down' means what side is 'up' could be used to solve this problem.
It should be possible to reconise using PoTrace or other similar raytracing program and (high contrast) dice what side the camera is looking at.
With common six sided dice it would find the edge of the dice, then count the dots (of certain volume) and look up in the table what number is 'up'. This would work with all six sided dice, including sphere cuts ones (which I favor despite the marked decrease in randomness).
With 'irregular' flat faced 4,8,10,12, 20 and 100 sided dice this gets slightly more complicated. While all of these have sides which are generally strait edged, they use numerals.
The software can 'learn' the dice by recording images of each side, and then straitening them out.
when rolled the outline of the dice is read to determine what type of dice it is (edges of dice, edges of face). Then this image is rotated level with each of the sides of the face, and compated to the table of this dice type for a best match.
With 'irregular' curved faced dice (3 and 5) the image is leveled with the furtest two points of the dice, not the face, since that will appear to be is gradient.
I would start with the python modules used with the multitouch since that is the only software that I've personally played with; however there may be other good (open source) options that I am ignorant of.
-
biscuit495
- Posts: 2
- Joined: Sat Oct 09, 2010 9:36 am
Re: Webcam object recognition-dice?
I see how it only needs to define one side of the die but I need the program to count the dots and record the numerical value each time. It needs to be in real time because the dice will be rolled several times per minute and need to be recorded several times per minute.
Re: Webcam object recognition-dice?
I'm not going to google the multitpouch for you, but it uses a webcam to detect multiple 'dots' of varying sizes in real time using raytracing and python.
-
Rekarp
- Portablizer Extraordinaire
- Posts: 2163
- Joined: Thu Dec 28, 2006 1:52 am
- PSN Username: Lnghrn_
- Steam ID: rekarp
- Location: Austin, Tx
- Contact:
Re: Webcam object recognition-dice?
This is easy (well easy for someone that does signal processing). You can do this in Matlab.
1.Take picture
2.Convert to Gray Scale
3.Threshold image at the 50% mark (dice are Black and white). This gives you an all black background, a white square with how many dots the side has.
4.Probably need to do some filtering to get rid of noise due to the webcam. (Open-Close filter)
5.Count how many black areas there are then subtract the background or run a edge routine to remove the background.
1.Take picture
2.Convert to Gray Scale
3.Threshold image at the 50% mark (dice are Black and white). This gives you an all black background, a white square with how many dots the side has.
4.Probably need to do some filtering to get rid of noise due to the webcam. (Open-Close filter)
5.Count how many black areas there are then subtract the background or run a edge routine to remove the background.
