An end-to-end automated solution for solving a 3x3 Rubik's Cube. This project combines real-time image processing to interpret the cube's state and mathematical algorithms to generate an optimal solve path.
The script utilizes a webcam to capture the six faces of the cube.
- HSV Color Segmentation: Unlike standard RGB, we use the HSV (Hue, Saturation, Value) color space to ensure robust detection under varying lighting conditions.
- Noise Reduction: Implements morphological transformations (
MORPH_OPENandMORPH_CLOSE) to filter out camera sensor noise and reflections on the stickers. - Dynamic Grid: A 3x3 UI overlay helps the user align the cube perfectly for scanning.
The core logic is powered by the kociemba Python library, which implements Herbert Kociemba's Two-Phase Algorithm.
- String Conversion: The script translates scanned colors into a 54-character string based on the center-piece map.
- Efficiency: Generates solutions typically under 20 moves.
- Format: Outputs standard Singmaster notation (e.g.,
U R2 F' B).
The solver includes a communication layer to bridge the software with a physical robot.
- Baudrate: Configured at
9600for stable Serial communication. - Auto-Detection: Automatically scans system ports to find an "Arduino" or "USB" serial device.
- Python 3.10+
- A Webcam
- Arduino Uno/Nano for mechanical solving
pip install opencv-python numpy pyserial kociemba