Giter VIP home page Giter VIP logo

rubiks_camsolver's Introduction

Rubiks_Camsolver

A Rubiks Cube Solver that extracts colors on the face through webcam and prints out the solution moves (working here). The Algorithm used to solve the rubiks cube is Kociemba Algorithm (read here).

Working

The Face of the cube is detected by Tiny YOLOv3 model trained on custom data prepared by Phone captures. The images were then labeled using labelImg and the annotations were generated.
A Tiny YOLOv3 model was then trained using this Awesome Repo, TrainYourOwnYOLO. The training process and explanation can be found in the notebook given above. After the training the weights file was generated (you can find it here), it was used along with the inference code in this repo to detect the faces of the cube in a video.
Once the cube face is detected, the box image is cropped and the colors of the faces are found. The colors of the faces are then used to generate Cube string which denotes the positions of the pieces of the cube.
To solve the cube, I used the library rubiks_solver which generates solutions for the cube in various methods.

Detecting the Face colors

The bounding box generated from tiny YOLOv3 was cropped to get a tight crop of the cube face. The face was then divided into 9 patches. From each patch I generated 9 sample pixels, the color of these pixels was found using its "Distance" from the predefined colors of the cube. Once the colors of the Pixels are found, the final color of the patch is decided through voting. This same process is applied on the 9 patches of a face and the colors of the face are found.

Usage

  1. If you want to use this project. I recommend using a virtual environment. The process can be found here.
  2. Once you have activated the virtual environment, Clone this repository, extract it if you downloaded a .zip or .tar file and cd into the cloned repository.
cd C:\rubiks_camsolver 
  1. Install the Requirements file
pip install -r requirements.txt
  1. Download the weights file from here and put it inside " detect_data " folder.
  2. Run the detector
python Detector.py
  1. Ignore the Deprecation warnings. You may not find a good color detection because of lighting conditions. To tune the detection values, take a screenshot of the video feed containing your cube, name it "Screenshot".
  2. Then run the color_tuner.py script. This opens up your screenshot. Click on any one color of the cube for example, yellow, keep clicking on various points of the yellow color, you can see that various values are printed on the terminal. These are the BGR values of the yellow in the image.
  3. Adjust the values in the face_detect.py script in the color dictionary. Do so for each color.
  4. Once done, you will have a working Rubiks cube solver.

References

YOLO TRAINING

  1. https://github.com/AntonMu/TrainYourOwnYOLO
  2. https://github.com/zzh8829/yolov3-tf2

RUBIKS CUBE SOLVING

  1. https://github.com/Wiston999/python-rubik
  2. https://github.com/mazenkurdi/rubiks-cube-solver
  3. https://github.com/pglass/cube

rubiks_camsolver's People

Contributors

varun221 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

hood-dwag simrit1

rubiks_camsolver's Issues

Model Weights

Where Can I find the Model weights because the links are not valid at current moment. So can you please let us know where can we find the model weights and also the dataset.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.