From 7b482b3bc77dc6051c558054c8a758455a48b7a4 Mon Sep 17 00:00:00 2001 From: sladro Date: Sun, 11 Jan 2026 20:33:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=8F=91=E8=B7=9F=E8=B8=AA=EF=BC=8C?= =?UTF-8?q?=E6=96=B0=E7=9A=84=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- configs/sample_cam1.json | 224 ++++++++++++++++++++++++++++++++++++++- plugins/osd/osd_node.cpp | 8 +- 2 files changed, 229 insertions(+), 3 deletions(-) diff --git a/configs/sample_cam1.json b/configs/sample_cam1.json index 1889d29..d2c754b 100644 --- a/configs/sample_cam1.json +++ b/configs/sample_cam1.json @@ -75,6 +75,24 @@ "dtype": "auto" } }, + { + "id": "trk_cam1", + "type": "tracker", + "role": "filter", + "enable": true, + "mode": "bytetrack_lite", + "per_class": true, + "track_classes": [], + "ignore_classes": [], + "allowed_models": ["yolov5", "yolov8"], + "high_th": 0.5, + "low_th": 0.1, + "iou_th": 0.3, + "max_age_ms": 1500, + "min_hits": 2, + "max_tracks": 128, + "debug": { "stats": false, "stats_interval": 200 } + }, { "id": "osd_cam1", "type": "osd", @@ -179,11 +197,215 @@ ["pre_cam1", "yolo_cam1"], ["yolo_cam1", "face_det_cam1"], ["face_det_cam1", "face_recog_cam1"], - ["face_recog_cam1", "osd_cam1"], + ["face_recog_cam1", "trk_cam1"], + ["trk_cam1", "osd_cam1"], ["osd_cam1", "post_cam1"], ["post_cam1", "pub_cam1"], ["pub_cam1", "alarm_cam1"] ] + }, + { + "name": "cam2_sample_full_pipeline", + "nodes": [ + { + "id": "in_cam2", + "type": "input_rtsp", + "role": "source", + "enable": true, + "url": "rtsp://10.0.0.5:8554/cam", + "fps": 30, + "width": 1280, + "height": 720, + "use_mpp": true, + "use_ffmpeg": false, + "force_tcp": true, + "reconnect_sec": 5, + "reconnect_backoff_max_sec": 30 + }, + { + "id": "pre_cam2", + "type": "preprocess", + "role": "filter", + "enable": true, + "dst_w": 640, + "dst_h": 640, + "dst_format": "rgb", + "keep_ratio": false, + "use_rga": true + }, + { + "id": "yolo_cam2", + "type": "ai_yolo", + "role": "filter", + "enable": true, + "infer_fps": 10, + "model_path": "./third_party/rknpu2/examples/rknn_yolov5_demo/model/RK3588/yolov5s-640-640.rknn", + "model_version": "v5", + "num_classes": 80, + "conf": 0.25, + "nms": 0.45, + "class_filter": [] + }, + { + "id": "face_det_cam2", + "type": "ai_face_det", + "role": "filter", + "enable": true, + "model_path": "./models/RetinaFace_mobile320.rknn", + "conf": 0.6, + "nms": 0.4, + "max_faces": 10, + "output_landmarks": true, + "input_format": "rgb" + }, + { + "id": "face_recog_cam2", + "type": "ai_face_recog", + "role": "filter", + "enable": true, + "model_path": "./models/mobilefacenet_arcface.rknn", + "align": true, + "emit_embedding": false, + "max_faces": 10, + "input_format": "rgb", + "input_dtype": "uint8", + "threshold": { "accept": 0.45, "margin": 0.05 }, + "gallery": { + "backend": "sqlite", + "path": "./models/face_gallery.db", + "load_on_start": true, + "expected_dim": 512, + "dtype": "auto" + } + }, + { + "id": "trk_cam2", + "type": "tracker", + "role": "filter", + "enable": true, + "mode": "bytetrack_lite", + "per_class": true, + "track_classes": [], + "ignore_classes": [], + "allowed_models": ["yolov5", "yolov8"], + "high_th": 0.5, + "low_th": 0.1, + "iou_th": 0.3, + "max_age_ms": 1500, + "min_hits": 2, + "max_tracks": 128, + "debug": { "stats": false, "stats_interval": 200 } + }, + { + "id": "osd_cam2", + "type": "osd", + "role": "filter", + "enable": true, + "draw_bbox": true, + "draw_text": true, + "draw_face_det": false, + "line_width": 2, + "font_scale": 1, + "labels": [] + }, + { + "id": "post_cam2", + "type": "preprocess", + "role": "filter", + "enable": true, + "dst_w": 1280, + "dst_h": 720, + "dst_format": "nv12", + "keep_ratio": false, + "use_rga": true + }, + { + "id": "pub_cam2", + "type": "publish", + "role": "filter", + "enable": true, + "codec": "h264", + "fps": 30, + "gop": 60, + "bitrate_kbps": 2000, + "use_mpp": true, + "use_ffmpeg_mux": true, + "outputs": [ + { "proto": "rtsp_server", "port": 8555, "path": "/live/cam2" }, + { "proto": "hls", "path": "./web/hls/cam2/index.m3u8", "segment_sec": 2 } + ] + }, + { + "id": "alarm_cam2", + "type": "alarm", + "role": "sink", + "enable": true, + "eval_fps": 10, + "labels": [], + "rules": [ + { + "name": "person_in_view", + "class_ids": [0], + "roi": { "x": 0.0, "y": 0.0, "w": 1.0, "h": 1.0 }, + "min_duration_ms": 0, + "cooldown_ms": 3000 + } + ], + "face_rules": [ + { "name": "unknown_face", "type": "unknown", "cooldown_ms": 5000, "min_sim": 0.0 }, + { "name": "known_person", "type": "person", "cooldown_ms": 5000, "min_sim": 0.5 } + ], + "actions": { + "log": { "enable": true, "level": "info" }, + "snapshot": { + "enable": true, + "format": "jpg", + "quality": 85, + "upload": { + "type": "minio", + "endpoint": "http://10.0.0.5:9000", + "bucket": "test", + "region": "us-east-1", + "access_key": "minioadmin", + "secret_key": "minioadmin" + } + }, + "clip": { + "enable": true, + "pre_sec": 5, + "post_sec": 10, + "format": "mp4", + "fps": 30, + "upload": { + "type": "minio", + "endpoint": "http://10.0.0.5:9000", + "bucket": "test", + "region": "us-east-1", + "access_key": "minioadmin", + "secret_key": "minioadmin" + } + }, + "http": { + "enable": false, + "url": "http://127.0.0.1:8080/api/alarm", + "timeout_ms": 3000, + "include_media_url": true, + "method": "POST" + } + } + } + ], + "edges": [ + ["in_cam2", "pre_cam2"], + ["pre_cam2", "yolo_cam2"], + ["yolo_cam2", "face_det_cam2"], + ["face_det_cam2", "face_recog_cam2"], + ["face_recog_cam2", "trk_cam2"], + ["trk_cam2", "osd_cam2"], + ["osd_cam2", "post_cam2"], + ["post_cam2", "pub_cam2"], + ["pub_cam2", "alarm_cam2"] + ] } ] } diff --git a/plugins/osd/osd_node.cpp b/plugins/osd/osd_node.cpp index 8605153..77918b2 100644 --- a/plugins/osd/osd_node.cpp +++ b/plugins/osd/osd_node.cpp @@ -431,8 +431,12 @@ private: } if (draw_text_) { - char label[64]; - snprintf(label, sizeof(label), "%s %.0f%%", GetLabel(det.cls_id), det.score * 100); + char label[96]; + if (det.track_id >= 0) { + snprintf(label, sizeof(label), "%s %.0f%% id=%d", GetLabel(det.cls_id), det.score * 100, det.track_id); + } else { + snprintf(label, sizeof(label), "%s %.0f%%", GetLabel(det.cls_id), det.score * 100); + } int text_y = y1 - 8 * font_scale_; if (text_y < 0) text_y = y1 + 2; DrawText(data, w, h, stride, fmt, x1, text_y, label, font_scale_, color);