Skip to content

erwinyo/People-High-Risk-Area

Repository files navigation

People-High-Risk-Area

High-Risk Area People Counting systems are designed to automatically monitor and count the number of individuals within designated zones using computer vision and machine learning techniques. These systems help enhance safety by detecting overcrowding in vulnerable areas, providing real-time insights, and supporting authorities in managing risks more efficiently.

Project Task List

No Task Status Notes / Issues
1 Database Setup [OK]
2 Livestream Source [OK]
3 Object Detection & Tracking [OK]
4 Polygon Zone & Counting [OK]
5 API Integration [OK]
6 Docker Deployment [OK]
7 Dashboard [X]

Demo

Watch the video

Livestream Video

If you want to change the source, below is the code location (inference/inference.py)

Video Source Code

System Design

System Design

  • "Area Update Interval Triggered?": It request updated data from database if any changes present (create, delete, update)
  • "Snap Interval Triggered?": It send captured scene (people inside and outside of area) been snapshot and registered on database
  • "Want Change Area?": It request an update of area and registered to database
  • "Want Status Count?": It request history or live status count

Tech Stack

  • Minio
  • MongoDB
  • YOLOv11
  • Supervision
  • Docker
  • FastAPI
  • OpenCV

Database Design

Below is the list of structure of collection on MongoDB:

Areas Areas collection

Peoples Peoples collection

Counts Counts collection

Docker Deployment

Video Installation

Watch the video

You have to have following already installed

Clone this project

git clone https://github.com/erwinyo/People-High-Risk-Area.git

Run docker compose up

docker compose -f docker-compose.yml up -d --build

Run .mpd file on the output/ folder

  • Open VLC media player
  • Click media, choose open file
  • Open .mpd file (located: /output/_/dash_out.mpd) *Note: the result is playable, but sometime lagging and stopped. Need refresh periodically.

Manual Deployment

Video installation

Watch the video

You have to have following already installed

Clone this project

git clone https://github.com/erwinyo/People-High-Risk-Area.git

Deploy MongoDB and Minio Containers

cd People-High-Risk-Area
docker compose -f docker-compose-manual.yml up -d --build

Run API

cd api
uv run python api.py

Run Inference

cd inference
uv run python inference.py

A window will be pop-up to show the inference

API Reference

Get counts status

  GET /api/stats
Name Type Required Default Description
start_time int No None Start timestamp (epoch) for filtering stats.
end_time int No None End timestamp (epoch) for filtering stats.
page int No 1 Page number for paginated results.
limit int No 10 Number of items per page.

Example Request

http://localhost:8000/api/stats?start_time=1758905345&end_time=1758905360&page=1&limit=10
http://localhost:8000/api/stats?page=1&limit=20

Get live count status

  GET /api/stats/live

Get all area

  GET /api/area

Create new area

  POST /api/set/area
Field Type Required Description
location str Yes The location identifier.
area_name str Yes The name of the area.
polygon_zone list[list[int]] Yes Polygon coordinates defining the zone.

Example Request

{
    "location": "kepatihan",
    "area_name": "depan_gerbang_masuk",
    "polygon_zone": [[735, 721], [1389, 682], [1757, 804], [891, 902]]
}
  POST /api/get/area
Field Type Required Description
location str Yes The location identifier.
area_name str Yes The name of the area.

Example Request

{
    "location": "kepatihan",
    "area_name": "depan_gerbang_masuk",
}
  POST /api/update/area
Field Type Required Description
location str Yes The location identifier.
area_name str Yes The name of the area.
polygon_zone list[list[int]] Yes Updated polygon coordinates for the zone.

Example Request

{
  "location": "kepatihan",
  "area_name": "depan_gerbang_masuk",
  "polygon_zone": [[735, 721], [1389, 682], [1757, 804], [891, 902]]
}
  POST /api/delete/area
Field Type Required Description
location str Yes The location identifier.
area_name str Yes The name of the area.

Example Request

{
  "location": "kepatihan",
  "area_name": "depan_gerbang_masuk"
}

Screenshots

Snap1

Snap2

Snap3

About

Track and count people on high risk area

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published