Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Construction Site Safety — AI-Powered PPE Detection & Fall Monitoring System

A full-stack web application that uses YOLOv8 computer vision models and MediaPipe pose estimation to enhance worker safety on construction sites. The system detects Personal Protective Equipment (PPE) compliance in real time and monitors video footage for fall incidents, automatically triggering alerts and email notifications when emergencies are detected.


Table of Contents


Features

1. PPE Detection (Image-Based)

  • Detects Hard Hats, Safety Vests, and Face Masks from uploaded images or live camera captures.
  • Uses two custom-trained YOLOv8 models:
    • best.pt — Detects hardhats, safety vests, boots, hooks, machinery, and persons.
    • best2.pt — Detects mask types (surgical, N95, KN95, cloth) and whether a mask is worn correctly.
  • Returns a SAFE / NOT SAFE verdict based on combined PPE compliance.

2. Fall Detection (Video-Based)

  • Analyzes uploaded video files for human fall events using MediaPipe Pose Estimation.
  • Uses a head-vs-hip vertical position heuristic to detect falls in real time.
  • On fall detection:
    • Triggers an audible siren alarm on the frontend.
    • Sends an automated emergency email to the designated supervisor via Gmail SMTP.

3. Nearby Hospitals Directory

  • Lists nearby hospitals with addresses, phone numbers, and distances.
  • Provides Google Maps navigation links for quick routing to the nearest medical facility.

4. First Aid Guidance

  • Accordion-based first aid reference for common construction site injuries:
    • CPR (Cardiopulmonary Resuscitation)
    • Bleeding Control
    • Fracture Management
  • Includes embedded YouTube video tutorials for each procedure.

Tech Stack

Layer Technology
Frontend React 19, React Router v7, React Bootstrap, Material UI, React Icons
Backend Python 3, Flask, Flask-CORS
CV/ML Ultralytics YOLOv8, OpenCV, MediaPipe Pose Estimation
Alerts SMTP (Gmail) for email notifications, Web Audio API for siren alerts

Project Structure

Construction-Site-Safety/
├── Backend/
│   ├── app.py                  # Flask server — main API (image upload, video upload, fall detection, email alerts)
│   ├── best.pt                 # YOLOv8 model weights — PPE detection (hardhat, vest, boots, etc.)
│   ├── best2.pt                # YOLOv8 model weights — Mask detection (surgical, N95, KN95, etc.)
│   ├── ppe_detection.py        # Standalone PPE detection script (video input)
│   ├── ppe_detection (1).py    # Alternate PPE detection script
│   ├── ppe.py                  # Standalone PPE detection script (image input)
│   ├── mask_detection.py       # Standalone mask detection script (video input)
│   ├── motiondetection.py      # Standalone fall detection script using MediaPipe
│   ├── download.py             # Utility script to download sample videos from YouTube
│   ├── req.txt                 # Python dependencies
│   ├── uploads/                # Temporary storage for uploaded images
│   ├── uploadsvideo/           # Temporary storage for uploaded videos
│   ├── img*.jpg                # Sample test images
│   └── v*.mp4                  # Sample test videos
│
├── Frontend_backup/
│   └── Frontend_backup/
│       └── detection/          # React application
│           ├── public/
│           │   └── index.html
│           ├── src/
│           │   ├── App.js
│           │   ├── App.css
│           │   ├── index.js
│           │   ├── index.css
│           │   ├── routes/
│           │   │   └── Routers.js          # Route definitions
│           │   ├── Components/
│           │   │   ├── Home.jsx            # Landing page with feature overview
│           │   │   ├── Dashboard.jsx       # PPE detection — camera capture & image upload
│           │   │   ├── Dashboard.css
│           │   │   ├── Falldetection.jsx   # Fall detection — video upload & siren alerts
│           │   │   ├── Falldetection.css
│           │   │   ├── Help.jsx            # Help section — hospital & first aid tabs
│           │   │   ├── HelpSection.css
│           │   │   ├── HospitalTab.jsx     # Nearby hospitals with map navigation
│           │   │   ├── FirstAidTab.jsx     # First aid guides with YouTube videos
│           │   │   ├── Header.jsx          # Navigation header
│           │   │   ├── Siren.jsx           # Siren alert component
│           │   │   └── CoreFeatures.css
│           │   └── Images/                 # Static assets (banners, icons, audio, etc.)
│           ├── package.json
│           └── .gitignore
│
├── .gitignore
└── README.md

Prerequisites

  • Python 3.8 or higher
  • Node.js 16 or higher and npm
  • Git
  • A webcam (optional, for live capture mode)

Installation

Backend Setup

# Navigate to the backend directory
cd Backend

# Create and activate a virtual environment
python -m venv venv
# Windows
venv\Scripts\activate
# macOS / Linux
source venv/bin/activate

# Install dependencies
pip install -r req.txt

# Additionally install mediapipe (required for fall detection)
pip install mediapipe

# Start the Flask server
python app.py

The backend server will start on http://127.0.0.1:5000.

Frontend Setup

# Navigate to the frontend directory
cd Frontend_backup/Frontend_backup/detection

# Install Node.js dependencies
npm install

# Start the development server
npm start

The React development server will start on http://localhost:3000.


Usage

  1. Home Page (/home) — Overview of the platform and its core features: Safety Detection, Fall Detection, Nearby Hospitals, and First Aid Guidance.

  2. PPE Detection Dashboard (/dashboard) — Two modes of operation:

    • Live Capture: Enable the webcam, capture a photo, and the system analyzes PPE compliance (hardhat, vest, mask).
    • Image Upload: Drag-and-drop or browse to upload an image for analysis.
    • The results panel shows detection status for each PPE item and an overall SAFE / NOT SAFE verdict.
  3. Fall Detection (/falldetection) — Upload a video file (MP4) and the system analyzes it for fall incidents using pose estimation. If a fall is detected:

    • A siren alarm sounds on the browser.
    • An emergency email is automatically sent to the configured supervisor.
    • The gauge UI reflects the detection result in real time.
  4. Help Section (/help) — Two tabs:

    • Nearby Hospitals: Displays a list of nearby hospitals with contact details and Google Maps navigation.
    • Basic First Aid: Accordion-style guides for CPR, bleeding control, and fracture management with embedded YouTube tutorials.

API Endpoints

POST /upload

Upload an image for PPE detection.

Request: multipart/form-data with a file field (PNG, JPG, or JPEG).

Response:

{
  "message": "File uploaded successfully",
  "filename": "example.jpg",
  "is_helmet_found": true,
  "is_vest_found": false,
  "is_mask_found": true
}

POST /upload_video

Upload a video for fall detection.

Request: multipart/form-data with a file field (video file).

Response:

{
  "message": "File uploaded successfully",
  "filename": "example.mp4",
  "is_fall_detected": true
}

Detection Models

Model File Task Classes
PPE Model best.pt PPE compliance detection Boots, Hardhat, Hook, Machinery, No-Hardhat, No-mask, No-safetyvest, Person, Safetyvest
Mask Model best2.pt Face mask type classification cloth, kn95, mask_weared_incorrect, n95, surgical, with_mask, without_mask

Both models are trained using Ultralytics YOLOv8 and loaded at server startup. Detection confidence threshold is set at 0.5.


License

This project is developed for academic and educational purposes.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages