Object Recognition from Templates
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 h开发者_运维问答aving 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
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:
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.
When the die has been located, find the eyes. This can be done by simply finding all black blobs.
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.
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!
精彩评论