Ask Your Question
2

detect and analyze a rubik cube

asked 2013-12-21 03:20:25 -0600

BoomerB gravatar image

Hi, I'm new top computer vision and need some advice where to start. I've written a application which displays a Rubik cube and lets me manipulate the cube like a real one. I also integrated a auto-solver button. Then I thought it would be nice if that button also existed in real life. So, I want to create an application which analyzes the cube with a camera and solves the cube with a robot. The first step would be to detect and analyze the cube through a camera. For this I think I need 3 things: - detect if the cube is visible by the camera - find out where in the picture the cube is and find the state of the current face (the colors of the sub-faces) - some kind of motion tracking to stitch the detected faces together. I went through the tutorials on opencv.org and was googling about feature detection / description / matching and object detection with haar / lbp. But I'm still not sure what's the best option to start with. - are features good enough - should I go for LBP - or even something completely different like neural networks

Can you please tell me how you would detect and analyze a Rubik cube? Thanks

Regards Bernhard

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-12-21 07:56:28 -0600

Guanta gravatar image

The more I think about it, the more complex it seems to me. What you describe consists indeed of the three steps you mention. To alleviate the problem I'd suggest that you start from something simpler:

  1. assume that the cube is in the image and
  2. exactly one face of the cube is looking towards the camera. Then you need to capture exactly 6 photos of your cube to know each face, thus you need to
  3. fix the capture order to assign the correct faces to your algorithm.

From this simpler problem, you need to locate the cube in the image / the nine stickers of each face. The steps are:

  • Grayscale conversion (cvtColor),
  • Canny edge detection (Canny()),
  • find the locations of the stickers (findContours()). Since findContours may give you more than you actually need, filter them: take the approximately squared contours (easy check via rotatedRec of each contour) and if no perspective transformation exists they all should approximately have the same size, too.
  • Now go through the original colored image using the nine contours and check their average color.

Having solved this easier problem you can then try to work on assumption 1 and detect that there is a cube at all, there you can use the cascade-classifier using e.g. LBP or HOG, which should work very good, since the rubic cube is an easy target (keypoint based method via feature detection/matching should work as well).

Assumptions 2 and 3 are imho the most difficult ones since you need to either a) build a model of the rubik cube with one camera drive over the whole cube, or b) to estimate which face the camera is currently looking at and then run the detection process as before, but finding the transitions between the faces (i.e. when does the face change) is the difficult part. Maybe some simple heuristics like: a) when are the nine stickers of one face clearly visible and b) a check if their configuration hasn't been captured yet could help here.

Good luck with your nice project! Let us know, when you are done or facing any issues.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-12-21 03:20:25 -0600

Seen: 4,219 times

Last updated: Dec 21 '13