The Canteen Ethics Monitoring System is an AI-powered solution designed to monitor and enforce ethics in canteen environments. It integrates various hardware, software, and cloud services to analyze, process, and respond to visual data collected in real time.
- Overview
- System Architecture
- Flow Diagram
- Project Directory Structure
- Technologies Used
- How It Works
- Setup and Deployment
- Credits
- License
The project follows a modular architecture divided into four levels:
- Frontend:
- Built with React Vite and styled using Tailwind CSS.
- Deployed using Vercel for seamless and scalable hosting.
- Purpose: Provides an intuitive interface for users to view monitoring results and system status.
- Backend:
- Powered by Express.js with Firebase Admin SDK.
- Deployed as a Vercel Serverless Function, optimized for fetching and displaying data.
- Google Cloud Compute Engine (VM Instance):
- Hosts Docker containers and manages image processing pipelines.
- Includes a supervisord service for running monitoring scripts:
scheduler_docker.py
: Schedules data uploads and synchronizations.watch_file_docker.py
: Monitors file changes and triggers the processing pipeline.
- Firestore Database & Firebase Storage:
- Used for storing processed results, metadata, and uploaded images.
- Acts as a centralized data hub for analysis and reporting.
- ESP32 CAM:
- Captures images and transfers them to the server via FTP.
- AI Level:
- YOLOv5x AI Model:
- Trained to detect specific behaviors and objects in the images.
- Developed and tested using Docker, ensuring consistent environments for training and deployment.
- YOLOv5x AI Model:
The flow diagram illustrates the interaction between various components of the system.
canteen-ethics-monitoring/
├── .git/ # Git repository for version control
├── CameraWebServer/ # For testing camera OV2640 via local IP
├── client/ # Frontend application (React Vite + Tailwind CSS)
├── esp32_cam/ # ESP32 CAM scripts for capturing and transferring images
├── fomo_esp32/ # ESP32 CAM scripts for edge computing using FOMO model AI builtins // Just for testing
├── vm_config_notes/ # Notes for configuring the Google Cloud VM instance
├── webapi/ # Backend API built with Express.js for handling data and Firebase integration
├── yolov5/ # Main algorithm of the model inference, tracking state, and firebase integration
│ ├── scheduler_docker.py # Schedules data upload
│ └── watch_file_docker.py # Watches for file changes to trigger processing
├── FlowDiagram.drawio # Editable flow diagram of the system
├── FlowDiagram.drawio.png # PNG version of the system flow diagram
├── LICENSE # License file for the project
└── README.md # Project documentation (this file)
-
Frontend:
- React Vite
- Tailwind CSS
- Vercel for hosting
-
Backend:
- Express.js
- Firebase Admin SDK
- Vercel Serverless Functions
-
Database:
- Firestore Database
- Firebase Storage
-
Hardware:
- ESP32 CAM for image capturing
-
AI:
- YOLOv5x for image recognition and behavior analysis
- Docker for consistent development environments
-
Cloud:
- Google Cloud Compute Engine (VM) for hosting Dockerized services
-
File Transfer:
- FTP for transferring images from ESP32 CAM to the VM instance
-
Image Capture:
- ESP32 CAM captures images in the canteen environment.
- Images are transferred to the Google Cloud VM instance via FTP.
-
Monitoring & Processing:
watch_file_docker.py
detects new images in the VM directory.- The trained YOLOv5s model processes the images for specific behaviors.
- Violation behavior will be save into tracking_state.json
- Results photo are stored in Firebase.
-
Scheduling Tasks:
scheduler_docker.py
handles periodic tasks, such as data upload from tracking_state.json.
-
User Interaction:
- Frontend displays processed results, accessible to users through a Vercel-hosted app.
- Navigate to the
client/
directory:cd client
- Install dependencies:
npm install
- Start the development server:
npm run dev
- Navigate to the backend directory (if applicable):
cd backend
- Install dependencies:
npm install
- Deploy as a Vercel Serverless Function
- Create a Google Cloud VM instance with Debian 11.
- Install Docker and Supervisord:
sudo apt update sudo apt install docker.io supervisor
- Deploy the Docker containers:
docker build -t canteen-monitor . docker run -d --name monitor-container canteen-monitor
- Flash the ESP32 CAM with the provided script in the
esp32_cam/
directory. - Configure the Wi-Fi credentials and FTP details in the script.
- Navigate to the
yolov5/
directory:cd yolov5
- Install dependencies in a virtual environment:
python -m venv venv source venv/bin/activate pip install -r requirements.txt
- Deploy the trained model in the Docker container using dockerfile.
Special thanks to the following for their contributions and resources that made this project possible:
- Firebase for providing a robust database and storage solution.
- Google Cloud for their reliable infrastructure.
- Leonardo Bispo Team: big thanks to Leonardo Bispo in https://github.com/ldab for developing ESP32_FTPClient.
This project is licensed under the MIT License. See LICENSE
for more details.