A DearPyGui-based application that scans a physical Rubik's Cube with a webcam using YOLO for detection, reconstructs face colors, and produces a solution using Kociemba's algorithm.
demo.mp4
- Python 3.9+
- Webcam (for scanning)
- Recommended GPU support for PyTorch (falls back to CPU)
- Python packages: in requirements.txt
Install the dependencies (PowerShell example):
python -m pip install -r requirements.txtAdjust the PyTorch install command for your CUDA version or use the CPU-only wheel if needed.
main.py— main GUI scanner/solver; runs the webcam pipeline and visualization.rubik_face_read.py— cube state representation, move application, and color extraction helpers.YOLO.pt— pretrained YOLO model for cube detection.
From the repository root:
python main.pyControls inside the app:
SPACE— capture the current faceR— redo the last captured faceC— clear all captured facesV— open 3D viewA— open solution animator- Arrow keys — rotate the 3D/animation view
Q— quit
Workflow:
- Align a cube face in the camera view (follow the order) and press
SPACEto capture each face. Guide:
- White (on top is blue) -> Yellow (on top is green) -> Green (on top is white) -> Orange (on top is white) -> Blue (on top is white) -> Red (on top is white).
- The app resolves colors, validates the state, and runs Kociemba to compute a solution string.
- Use
Vto inspect the reconstructed cube in 3D. - Use
Ato play/pause/step through the solution animation.
- Webcam not opening: ensure no other app is using the camera; check the
cv2.VideoCapture(0)index inmain.py. - Slow inference: confirm PyTorch is using CUDA; otherwise it will run on CPU.
- Color misreads: verify lighting and try recapturing faces; adjust thresholds in
rubik_face_read.pyif needed. - Kociemba install error: This is a classic error when programming Python on Windows. Cause: The
kociembalibrary (Rubik solving algorithm) is written in C for speed. When you usepip install, it tries to compile this C source code on your machine, but your machine lacks the compiler toolset named Microsoft Visual C++ Build Tools.
MIT License (see LICENSE).