Ask Your Question
1

Computer Vision - Craps Coach Project from a Newbie

asked 2012-07-30 10:19:57 -0600

penfold1972 gravatar image

updated 2012-07-30 12:00:06 -0600

I am really new to OpenCV and have been poking around for a month or two now trying to learn it by attempting to build an application that will help me and my friends play craps and keep things straight, especially while drinking. Since I am so new, I figure I will give as complete a description of my goals and understanding of what I think I should be doing so someone can explain where I am confusing myself and either making a task more complicated than it should be, or not understanding how complicated my approach actually is.

I suppose my explanation will be easier with an idea of the images I am working with. The background can be found here: craps-background.jpg and a "sample" of the objects I want to detect is here: craps_circle_test.jpg

My immediate goal is to have one camera mounted so it can see the whole board, recognize the play area, detect objects (dice, chips, markers) and facilitate play by keeping track of the point, and marking bets that win or loose. Ultimately, I want to tie in a projector that can provide feedback directly on the table and use stereo vision so I can identify objects in 3D to determine that this object consists of x number of chips of varying denominations and more accurately track a bet and calculate the winnings, or detect that a dice came to rest on a chip, but I'm taking this in baby steps and not really worried about the end goals just yet.

My reading and tinkering has gotten me to the point of having some code that can read the image from the camera and at least show a mask of the playing field to become familiar with the concepts of computer vision. I have also incorporated the squares sample so it can show the area of the playing field. (Still need to limit this to the single largest square, but I am getting the feeling I might be going in the wrong direction.)

Isolating the green field in a black and white threshold image gives me not only the playing area and the outer region where the players stand (which can be ignored) but also does a really good job of showing the objects on the playing area that I can probably use to track objects, but is mingled with the different patterns on the playing field to designate what bets are in play.

I suspect that I am not approaching the problem correctly which is why I am getting lost in the best way to process this and my question is if someone has some advice on how to properly approach this issue?

I think I should threshold on the green felt, and ignore (mask) all the pixels outside of that area, and somehow mark that this area is the playing field. Then I should somehow find, mark and mask the playing field's printed area as well as the green ... (more)

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2012-07-30 19:48:15 -0600

Hi Steve!

I think this is a very nice project to get a good insight of what computer vision is all about. You are going to get all kinds of things on your way: unwanted shadows, noise, occlusions... But any way, the effort would be worth it when you have your neat craps system up and running.

About your problem, if you want to segment the objects on your playing area, how about using Background Subtraction (or Background Differencing) instead of just thresholding on the green color?

To perform Bacground Subtraction you should first learn a model of the background, then compare that model to your current image and subtract away the known background parts. The objects left after subtraction will likely be foreground objects (i.e: your chips, dice, etc..)

You can find plenty of information on internet about it. But I would recommend you these books:

Chapter 9 of the Book: "Learning OpenCV Computer Vision with the OpenCV Library". Gary Bradsky & Adrian Kaehler.  
Chapter 10 (p.272) of the Book: "OpenCV 2 Computer Vision Application Programming Cookbook". Robert Laganiere.

I hope this could be helpful for you.

edit flag offensive delete link more

Comments

I actually have both those books, and have tried to read them. Most of goes right over my head. I had t go to Khan Academy on YouTube, to get a basic understanding of matrices. That is where I am starting to get worried that I just don't have the higher math education to understand the theories enough to put the libraries to proper use. Which is why I have turned here to at least see if any of the approaches I have in mind are a just the wrong approach.

For example, I have the threshold generating a mask and am mostly done identifying the area where the playing field is in the picture. Then I spent a few hours trying to get the square which would be my ROI, when it occurred to me that it still leaves me with a huge green area that is pixels ...(more)

penfold1972 gravatar imagepenfold1972 ( 2012-07-30 20:31:24 -0600 )edit

Oh, and you mentioned I'm going to hit shadows, and noise. I am hitting those as well, but haven't gotten to the point I am ready to do much about them other than play with erode and dilate functions. As I mentioned above, I am still trying to wrap my head around the basic theories that need to be implemented. I did check out your blog and will probably hit your examples when I start to tackle the stereo vision portions of this idea.

And thanks for you advice! Every thing I can find to keep me on the right track and help make things click are greatly appreciated!

penfold1972 gravatar imagepenfold1972 ( 2012-07-30 22:42:19 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2012-07-30 10:19:57 -0600

Seen: 938 times

Last updated: Jul 30 '12