Skip to content

BradleyNgu/cuHacking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

31 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MLH Best Domain Name from GoDaddy Registry πŸ†

Waste Sorting System

A comprehensive automated waste sorting system that uses computer vision, machine learning, and a servo mechanism to sort waste items into recycling and garbage. The system includes a web analytics dashboard and a database for tracking sorting history.

Features

  • Computer Vision Classification: Automatically identifies cans, recyclables, and garbage
  • Automatic Sorting: Mechanically sorts items into appropriate bins using a servo-controlled platform
  • Analytics Dashboard: Web interface to view statistics and sorting history
  • Custom Model Training: Train your own classification model for better accuracy
  • Data Tracking: Store images and sorting data for analysis

System Requirements

Hardware

  • Arduino Uno or compatible board
  • High-torque servo motor (at least 15-20 kg-cm torque)
  • Logitech Brio 4K webcam (or similar high-resolution camera)
  • Computer with USB ports (Windows/Mac/Linux)
  • 5V 3A power supply for servo
  • Wood and acrylic materials for the physical platform

Software

  • Python 3.8 or newer
  • TensorFlow 2.x
  • OpenCV
  • SQLite
  • Flask (for web dashboard)
  • Arduino IDE (for uploading firmware)

Directory Structure

waste-sorting-system/
β”œβ”€β”€ arduino/                  # Arduino firmware
β”‚   └── waste_sorter_arduino.ino
β”œβ”€β”€ data/                     # Data storage directory
β”‚   β”œβ”€β”€ counts.json           # Counter values
β”‚   └── sorting_data.db       # SQLite database
β”œβ”€β”€ logs/                     # Log files
β”œβ”€β”€ models/                   # Trained models
β”‚   β”œβ”€β”€ latest_model.h5       # Latest model
β”‚   └── class_mapping.json    # Class mapping
β”œβ”€β”€ static/                   # Static web files
β”‚   β”œβ”€β”€ css/
β”‚   β”œβ”€β”€ js/
β”‚   └── img/
β”œβ”€β”€ templates/                # HTML templates
β”œβ”€β”€ training_data/            # Data for model training
β”‚   β”œβ”€β”€ can/
β”‚   β”œβ”€β”€ recycling/
β”‚   └── garbage/
β”œβ”€β”€ app.py                    # Web dashboard Flask app
β”œβ”€β”€ database.py               # Database module
β”œβ”€β”€ main.py                   # Main application
└── train_model.py            # Model training script

Installation

1. Clone the Repository

git clone https://github.com/BradleyNgu/cuHacking.git
cd cuHacking

2. Install Python Dependencies

pip install -r requirements.txt

Or manually install the following packages:

pip install tensorflow opencv-python numpy pillow pyserial flask matplotlib

3. Set Up Arduino

  1. Open Arduino IDE
  2. Load the firmware from arduino/waste_sorter_arduino.ino
  3. Connect your Arduino via USB
  4. Upload the firmware to the board

4. Create Directory Structure

mkdir -p data logs models static/css static/js static/img templates training_data/can training_data/recycling training_data/garbage

Building the Hardware

Materials List

  • Wood:

    • Base: 24" x 24" x 3/4" plywood
    • Sides: 2x 24" x 16" x 1/4" plywood
    • Back: 1x 24" x 16" x 1/4" plywood
  • Acrylic:

    • Platform: 12" x 10" x 1/8" clear acrylic
    • Side Rails: 2x 10" x 2" x 1/8" clear acrylic
  • Hardware:

    • Metal Axle: 1/4" diameter steel rod, 14" long
    • Ball Bearings: 2x flanged ball bearings for 1/4" shaft
    • Mounting Brackets: 2x metal L-brackets for bearings
    • Shaft Collars: 2x for securing axle
    • Servo Horn: Extended servo horn (6-8")
    • Screws, nuts, bolts, washers
  • Bins:

    • 2x plastic bins (approximately 10" x 10" x 12")

Assembly Instructions

  1. Build the Frame:

    • Assemble the U-shaped frame using the plywood pieces
    • Secure with wood screws
    • Ensure corners are square
  2. Install the Pivot Mechanism:

    • Mount the bearing brackets at the center height on both sides
    • Insert the axle through both bearings
    • Secure with shaft collars
  3. Create the Tilting Platform:

    • Cut the acrylic platform and side rails
    • Attach side rails to the platform
    • Mount platform on the axle
  4. Install the Servo:

    • Create a sturdy mount for the servo
    • Attach the extended servo horn to the underside of the platform
    • Position ~5" from the pivot point for best leverage
  5. Mount the Camera:

    • Create a bracket to hold the webcam above the platform
    • Position it for a clear view of items
  6. Connect Electronics:

    • Connect the Arduino to your computer via USB
    • Connect the servo to the Arduino (signal wire to pin 9)
    • Connect servo power to external 5V power supply

Running the System

1. Start the Main Application

python main.py

2. Connect to Hardware

  • Select the Arduino port from the dropdown
  • Select the camera from the dropdown
  • Click "Connect"

3. Begin Sorting

For manual operation:

  • Place item on the platform
  • Click "Analyze Item"
  • Click "Sort Item" once analysis is complete

For automatic operation:

  • Check "Auto-Sort Mode"
  • Place items on the platform one at a time

4. Start the Analytics Dashboard

From the application menu:

  • Go to Tools > Start Analytics Dashboard

Or start it separately:

python app.py

Access the dashboard at http://localhost:5000

Training Your Own Model

  1. Collect images for each category:

    • Place images in the appropriate folders under training_data/
    • Aim for at least 50-100 images per category
  2. Launch the training dialog:

    • From the main application, go to Tools > Model Training
    • Set parameters and click "Start Training"
  3. Restart the application to use the new model

Troubleshooting

Arduino Connection Issues

  • Ensure the correct port is selected
  • Verify the Arduino has the correct firmware
  • Check the USB cable connection
  • Test with Tools > Test Arduino

Camera Issues

  • Verify the camera is connected
  • Try a different USB port
  • Test with Tools > Test Camera
  • Check for other applications using the camera

Sorting Problems

  • Calibrate the platform angles using the slider
  • Ensure the servo has enough power (use external power supply)
  • Make sure the platform surface is smooth
  • Check if items are within the weight limit of the servo

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

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

About

When you recycle a water bottle, do you leave the cap on or off? We don't know the answer, and neither do you. If only we could stay eco-conscious consumers despite the knowledge gap.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors