In our busy routines, sorting waste is often neglected, leading to biodegradable and non-biodegradable waste being mixed in the same bin. This creates a manual segregation bottleneck downstream. This project introduces a smart waste detection system that automatically classifies objects as biodegradable or non-biodegradable in real-time. By utilizing a Raspberry Pi, a USB camera, and the CircuitDigest Cloud Waste Detection API, you can deploy an automated waste-segregation system without collecting datasets, labeling data, or training complex AI models locally.
- Real-Time Classification: Detects and classifies waste as biodegradable or non-biodegradable in seconds using cloud-based AI.
- Multiple Operating Modes:
- Keyboard Mode: Capture images manually by pressing the
SPACEkey. - Auto Mode: Automatically captures images at a fixed time interval (e.g., every 5 seconds).
- SSH Mode: Runs in headless mode via terminal access without showing an OpenCV feed window.
- Keyboard Mode: Capture images manually by pressing the
- Zero Local Overhead: Eliminates the need for GPU-heavy local processing or platforms like TensorFlow Lite and Edge Impulse.
- Versatile Deployment: Ideal for smart bins in public places, offices, malls, or sorting facilities.
- Raspberry Pi (Pi 3, Pi 4, or newer, connected to external power)
- USB Web Camera (For capturing images of waste items)
- Laptop/PC (For initial setup and result observation)
- MicroSD Card (with Raspberry Pi OS installed)
- Place the USB camera in a position where waste items can be clearly presented to it.
- Connect the USB camera to one of the USB ports on the Raspberry Pi.
- Ensure the Raspberry Pi is powered using a sufficient external power source.
- Setup your Raspberry Pi using the Raspberry Pi Imager with a standard OS installation.
- Create an account on the CircuitDigest Cloud.
- Navigate to the Waste Detection feature and copy your API Key.
- Open Thonny IDE (or your preferred editor) on the Raspberry Pi.
- Install the necessary Python packages:
pip install opencv-python requests
- Clone this repository or copy the Python script to your Raspberry Pi.
- Edit the script to configure your parameters:
SERVER_URL = "https://www.circuitdigest.cloud/api/v1/waste-detection/detect" API_KEY = "YourApikey" # <-- Paste your CircuitDigest API Key here MODE = "keyboard" # <-- Set to "keyboard", "auto", or "ssh" AUTO_INTERVAL = 5 # <-- Interval in seconds for auto mode
- Run the script:
python waste_detection.py
- Depending on the mode selected, the system will capture images of the waste, transmit them securely to the CircuitDigest Cloud API, and output whether the item is biodegradable or non-biodegradable in the terminal.
- Camera not found! Check USB camera connection:
Verify the physical connection of the camera. If multiple video devices are connected, you may need to update the device index from
cv2.VideoCapture(0)tocv2.VideoCapture(1). - API request timeout: Verify that your Raspberry Pi has active and stable internet access. You can increase the timeout limit in the script.
- Invalid API key error: Re-verify that your API key is correctly copied from the CircuitDigest Cloud and pasted into the script without extra spaces.
- Incorrect waste classification result: Ensure the waste object is well-lit and fully visible to the camera. Avoid blurry shots or angled perspectives that obscure the item.
- Program crashes during execution: Ensure OpenCV and Requests libraries are installed properly. Restart the Raspberry Pi or script if the camera stream encounters an error.
| Advantages | Limitations |
|---|---|
| Automatically segregates biodegradable & non-biodegradable waste in real time | Requires a stable internet connection for cloud processing |
| Reduces manual work and simplifies recycling sorting | Classification accuracy depends on image clarity and camera quality |
| Low hardware entry point using standard USB webcams | Poor lighting or overlapping objects can impact results |
| Supports automatic intervals or manual keyboard captures | API limits might apply depending on your subscription |
| Promotes cleaner smart city/household waste management | Slight transmission latency for sending images over the network |