Skip to content

Code-With-Devansh/Rubiks-Cube-Solver

Repository files navigation

Rubik's Cube Solver: Computer Vision & Robotics

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.

Project Components

1. Computer Vision (OpenCV)

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_OPEN and MORPH_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.

2. Solving Logic (Kociemba Algorithm)

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).

3. Hardware Integration (Serial)

The solver includes a communication layer to bridge the software with a physical robot.

  • Baudrate: Configured at 9600 for stable Serial communication.
  • Auto-Detection: Automatically scans system ports to find an "Arduino" or "USB" serial device.

Installation & Setup

Prerequisites

  • Python 3.10+
  • A Webcam
  • Arduino Uno/Nano for mechanical solving

Dependency Installation

pip install opencv-python numpy pyserial kociemba

Releases

No releases published

Packages

 
 
 

Contributors

Languages