swampbear / HandyRecipes

Recipe application with functionality to move through recipes with hand gestures
MIT License
0 stars 0 forks source link

HandyRecipes

A recipe webapp containing tasty recipes and a gesture based step treversal feature. By simply showing your indexfinger to the camera you can move trough the different recipe steps. Never get fat, flour and other ingridients spilled over your device ever again!

Imports used and handrecognition class

OpenCV

Used to access camera from device

Mediapipe

Mediapipe is used together with open cv to create functions for fingerUp find position and so on described in the mediumarticle below. The most important for us in this project is tp utilize the fingerUp method and connecting it to events suiting our usecases

Class for drawing nodes and edges, and register fingers, or combination of fingers

The class in the hand_estimation.py is retrieved from the following Medium article: Hand Detection Tracking in Python using OpenCV and MediaPipe

Features

Honorable mention to chatGPT for creating these great bulletpoints

Project Structure

project-root/
├── database/
│   └── recipes.json             # JSON file storing all recipe data
├── models/
│   ├── Recipe.py                # Recipe model with components and ingredients
│   ├── RecipeComponents.py      # RecipeComponents model to represent components of a recipe
│   ├── Ingridient.py            # Ingredient model for individual ingredients
│   └── Steps.py                 # Step model containing step number and description
├── pages/
│   ├── home_page.py             # Streamlit page to display the home page
│   ├── recepies_page.py         # Streamlit page where you can choose what dish you want to displays
│   └── recipe_page.py           # Streamlit page to display recipe details
├── service/
│   └── RecipeService.py         # Service layer to fetch and parse JSON recipes
├── app.py                       # Main file to run the Streamlit app
├── .gitignore                   # Git ignore file, ignoring .pyc and __pycache__
└── README.md                    # Project README file

JSON Recipe File (recipes.json)

The recipe data is stored in a structured JSON file format within the database directory. Each recipe contains:

Example Recipe JSON Structure

{
  "recipes": [
    {
      "title": "Spaghetti Carbonara",
      "description": "A classic Italian pasta dish made with eggs, cheese, pancetta, and pepper.",
      "estimated_time": "15-20 min",
      "difficulty": "medium",
      "portions": 2,
      "recipe_components": [
        {
          "name": "Pasta Base",
          "ingredients_per_portion": [
            {
              "name": "Spaghetti",
              "measurement_type": "grams",
              "amount_per_portion": 100
            },
            {
              "name": "Pancetta",
              "measurement_type": "grams",
              "amount_per_portion": 50
            }
          ]
        },
        {
          "name": "Sauce",
          "ingredients_per_portion": [
            {
              "name": "Eggs",
              "measurement_type": "units",
              "amount_per_portion": 1
            },
            {
              "name": "Pecorino Romano",
              "measurement_type": "grams",
              "amount_per_portion": 25
            },
            {
              "name": "Black Pepper",
              "measurement_type": "teaspoon",
              "amount_per_portion": 0.5
            }
          ]
        }
      ],
      "steps": [
        {
          "number": 1,
          "description": "Boil the spaghetti in salted water until al dente."
        },
        {
          "number": 2,
          "description": "In a separate pan, cook the pancetta until crispy."
        },
        {
          "number": 3,
          "description": "Whisk eggs and Pecorino Romano together."
        },
        {
          "number": 4,
          "description": "Combine pasta with pancetta and mix with egg mixture, stirring quickly."
        },
        {
          "number": 5,
          "description": "Serve immediately with extra Pecorino and black pepper."
        }
      ]
    }
  ]
}

Installation

  1. Clone the Repository:

    git clone https://github.com/your-username/HandyRecipes.git
    cd HandyRecipes
  2. Create and activate viritual environtment

    python3 -m venv <myenvname>
  3. Activate environtment

    source myvenvname/bin/activate
  4. Install Dependencies:

    • Ensure you have Python 3.7+ and install required libraries:
      pip install -r requirements.txt
  5. Run the Streamlit Application:

    streamlit run app.py

Usage

License

This project is licensed under the MIT License. See the LICENSE file for details.