From 5e388f7fdcdd09d124a61caf7a5935481286dd1f Mon Sep 17 00:00:00 2001 From: Jakob Lechner Date: Sat, 2 Aug 2025 04:26:14 +0200 Subject: [PATCH 1/2] Update README --- README.md | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 54d2d95..47091e0 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,21 @@ # People Counter with YOLOv8, ByteTrack, and Prometheus -This project implements a real-time people counting system based on object detection and tracking using [YOLOv8](https://github.com/ultralytics/ultralytics) and [ByteTrack](https://github.com/ifzhang/ByteTrack). It supports **RTSP input**, **in/out counting** using a vertical line, and exposes **Prometheus metrics** for integration with monitoring systems. +This project implements a real-time people counting system based on object detection and tracking using [YOLOv8](https://github.com/ultralytics/ultralytics) and [ByteTrack](https://github.com/ifzhang/ByteTrack). It supports **MJPEG input**, **in/out counting** using either a vertical or a horizontal line, and exposes **Prometheus metrics** for integration with monitoring systems. ## 🚀 Features -- 🎥 RTSP camera stream input +- 🎥 MJPEG camera stream input - 🧠 YOLOv8 person detection - 🔁 ByteTrack object tracking -- ➕➖ In/Out counting via virtual vertical line +- ➕➖ In/Out counting via virtual line - 📊 Prometheus metrics at `http://localhost:9100/` -- 🌐 Streamlit UI for live video and statistics +- 🌐 Web UI for live video and statistics -## Start mediamtx +## Start MJPEG stream from webcam -``` -mediamtx -``` - -## Stream webcam - -``` -ffmpeg \ - -vaapi_device /dev/dri/renderD128 \ - -y \ - -f v4l2 \ - -framerate 30 \ - -video_size 1280x720 \ - -input_format mjpeg \ - -i /dev/video0 \ - -vf 'format=nv12,hwupload' \ - -c:v h264_vaapi \ - -f rtsp \ - rtsp://localhost:8554/cam -``` +mjpg_streamer -i "input_uvc.so -d /dev/video0 -r 1280x720 -f 30" -o "output_http.so -p 8080" ## Run application ``` -streamlit run streamlit_app.py +uvicorn main:app --host 0.0.0.0 --port 8000 ``` From 1d99f3887654613dc1298f41d6663154341472a8 Mon Sep 17 00:00:00 2001 From: Jakob Lechner Date: Sat, 2 Aug 2025 04:27:09 +0200 Subject: [PATCH 2/2] Do not skip frames --- tracker.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tracker.py b/tracker.py index b11ca20..73d251c 100644 --- a/tracker.py +++ b/tracker.py @@ -15,7 +15,6 @@ STREAMS = { "Kasse 2": "http://192.168.11.230:8080?action=stream", } -FRAME_SKIP = 2 model = YOLO("yolo_weights/yolo11n.pt") latest_frames = {} @@ -26,7 +25,6 @@ def process_stream(stream_id, url): line_orientation = "vertical" counter = Counter(stream_id, line_orientation, metrics) cap = cv2.VideoCapture(url) - frame_idx = 0 while cap.isOpened(): ret, frame = cap.read() @@ -36,9 +34,6 @@ def process_stream(stream_id, url): height, width, _ = frame.shape - frame_idx += 1 - if frame_idx % FRAME_SKIP != 0: - continue try: results = model.track(