A Flask API that receives 6 centered images of a scrambled Rubik's Cube and returns the cube string (color layout) by detecting each sticker's color using OpenCV and a trained KNN model in HSV space.
- Cuby Client - Main desktop application
- Cuby Mobile App - Mobile version
- Cuby Solve API - Cube solving algorithm API
- Cuby Capture API - Cube state capture API
- Cuby Capture Website - Web interface
- 📷 Color detection from HSV-processed images
- 🤖 KNN classifier trained on HSV color samples
- 🧪 Full test suite: unit, integration
- 🐳 Docker-ready + GitHub Actions CI/CD
- 🔄 Real-time color recognition
- 📊 High accuracy color detection
- Python 3.10+
- OpenCV
- Flask
- Scikit-learn
- Clone the repository:
git clone https://github.com/Cuby-Project/Cuby-recognition-API.git- Install dependencies:
pip install -r requirements.txt- Generate and train color model:
make trainThis runs:
generate_synthetic_dataset.py: generates HSV data for W, Y, R, O, B, Gtrain_color_model.py: trains and saves a KNN classifier
Method: POST
Content-Type: multipart/form-data
Fields: Upload 6 images named exactly:
face1,face2,face3,face4,face5,face6
Returns:
{
"cube_string": "UUUUUUUUURRRRRRRRRFFFFFFFFFDDDDDDDDDLLLLLLLLLBBBBBBBBB"
}Optional (if solver is included):
{
"cube_string": "...",
"solution": "R U R' U'"
}make testmake coveragemake docker-testdocker build -t rubik-api .docker run -p 5000:5000 rubik-apiContributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.