The Cube Solver program utilizes Kociemba and OpenCV libraries to swiftly provide a solution for a Rubik's Cube.
-
Capture Images: Take two pictures of your Rubik's Cube, ensuring that in each image, three faces of the cube are clearly visible. For optimal results, ensure that your cube has a black base and that the background is a single color. You may take pictures on a blank paper page and crop the images to display only the cube.
-
Run the Program: Execute the program from the
Cube_Solver.exe
file. You will be prompted to select the two photos you captured. -
View Solution: The solution will be printed to your console.
The program employs various image processing techniques to analyze the cube images:
-
Canny Edge Detection: The initial step involves applying the Canny edge detection algorithm to the images.
-
Hough Transform: The program utilizes the Hough transform to detect lines in the images, specifically looking for lines with specific angles associated with cube faces.
-
Thresholding: Filtering methods are employed to determine appropriate threshold values for both the Canny edge detection and Hough transform.
-
Line Filtering: The detected lines are further filtered to retain only relevant lines associated with the cube's edges.
-
Intersection Calculation: With seven lines for each angle, the program calculates the intersections between lines to determine the exact area for each cubicle of the cube.
-
Color Extraction: Once the cubicle areas are determined, the program extracts the most dominant colors from common Rubik's cube colors within each area.
-
Face Mapping: The extracted colors are used to create three cube-face-like arrays containing the colors of each face. This process is repeated for both images, resulting in all six faces of the cube being mapped to arrays.
-
Solution Generation: Using the mapped cube faces, the program creates the string format expected by Kociemba and prints the solution to the console.
- Python 3.x
- OpenCV
- Kociemba
- Ensure your images contain only the cube with no background shades or noise
- Ensure that your images are clear and well-lit for optimal results.
- Experiment with different backgrounds and lighting conditions to improve the accuracy of color extraction.
Examples of properly captured images can be found in the provided pictures.zip
file.
- Adding shade and noise robustness to the Canny filter phase.
- Providing more accurate color detection algorithm
- This project is private. you may contact me for any explanations and further discussion.