views:

205

answers:

1

Hi Guys,

I was hoping someone could point me in the right direction here. With a picture of a die (from above) I want to recognize which side is up.

I understand the basics in play here, but I'm having trouble grasping the power of OpenCV. I imagine I want a picture of each side of the die. Then I can somehow compare them all to the current image to be classified. How can I use OpenCV to do this?

Thanks, Jonathan

+2  A: 

While that would work and OpenCV has template matching functions, it would probably be harder than necessary. Good results would require that the lighting is more or less unchanged between all images, and that the camera is fixed and no projective distorsions occur.

Instead, I would do something like this:

  1. In the image, locate the die. The difficulty here will vary with regard to how the die looks and the background. If you have a white die on a lpain black (or some other color) background then finding the die will be easy.

  2. When the die has been located, find the eyes. This can be done by simply finding all black blobs.

  3. If necessary, make sure that the found eyes form a coherent pattern. E.g. if the side up is four you expect to find the eyes as the corners in a square, not on a straight line.

  4. Count valid eyes. There's your side up.

This outline is quite vague as there are lots of ways of performing each step. I do however believe that everything you need is available in OpenCV. Good luck!

kigurai
+1 Nice rephrasing of a much easier approach to the problem.
tom10