How to solve a Rubicks cube using OpenCV,python and RaspberryPi

The idea is to hold the face of a Rubik's cube in front of a webcam and the computer vision algorithm detects the position of the face within the webcam picture and identifies the facelet stickers together with their colors. Subsequently, the program solves the cube with the two-phase-algorithm.

This recognition task is so simple for the human eye that you usually will not waste a single thought on this – but if you try to implement this as a computer algorithm it takes some effort to get a reasonable result. Herbert Kociemba uses the opencv framework and Python in his project and got good results on a PC with a USB webcam and also with the Raspberry Pi and its non-USB camera module.

This project implements the two-phase-algorithm in its fully developed form to solve Rubik’s cube in Python. Though Python is much slower than for example C++ or even Java the implementation is sufficiently fast to solve random cubes in less than 20 moves on average on slow hardware like the Raspberry Pi3 within a few seconds.

If you just want to solve Rubik’s cube and play around with its patternsĀ Cube ExplorerĀ may be the better choice. But if you want to get a better understanding of the two-phase-algorithm details, you work on a project to build a cube solving robot or you write software for an NxNxN cube and use the reduction method this may be the right place to look.

You can download the project on Github and here is anĀ example of the solver in action, andĀ here another one.

Previous Story

WATCH Samsung first look 2021 event

Next Story

Cell C migrates its customers to MTN