Augmented Reality Rubiks Cube

cube_opener
Setup for the augmented rubiks cube solver
Setup for the augmented rubiks cube solver

The rubiks cube can be hard to solve by hand. Computer programs can make it a lot easier to bring the cube back to its original configuration. However following a list of rotation instructions can be complicated when they need to be transfered from textual form to the object in hand.  This project implements an Augmented Reality guide for solving the rubiks cube. The cube is placed flat on a table and a camera is mounted facing downwards looking at the top surface. The image from the camera is analyzed on a standard PC and used to calculate the solution as well as show it to the user.

 

The user goes through an initial stage where all sides of the cube are scanned. Once the model of the cube has been completed the (shortest) solution is calculated. The display shows the instructions to solve the cube by directly overlaying information on to the camera image. Instructions can be shown independently of which side the user turns upwards.

The image analysis is based on the hough transform. With this method all contour pixels have to be isolated first which is done using the sobel operator. Each contour pixel is then transformed into the family of all straight lines that go through this point described by angle and distance to the origin. The hough room contains a point for each line that is extracted from the image. To reduce complexity of calculation the room is quantized as a 2d-array. Every time a line is transfered to the hough room the corresponding value in the array is increased. After all contour pixels have been transfered the highest value in the array decides the line that is supported by the most pixels in the image. To further speed up the transformation the family of lines is reduced to those that correspond with the gradient of the current pixel and its neighbors.

To find the corners of the cube the four highest maxima in the hough space are searched. If the analysis was correct they describe the four outside edges of the cube. The corners can be found by calculating their intersections. Afterwards the color values of pixels corresponding to the cubes grid are extracted to find the 9 colored faces. The center face is then used to identify the side of the cube since it can only be rotated but not moved to a different side.