Ryan123Nguyen's picture
Add runtime bundle (104 files, 121.85 MB)
7baad7b verified
Raw
History Blame
13.7 kB
[plugin]
name = "traffic_violation_detection"
version = "5.3.0"
display_name = "Phát hiện vi phạm giao thông"
description = "Phát hiện vi phạm giao thông: vượt đèn đỏ, sai làn, ngược chiều, không đội mũ, quay đầu xe, quá tốc độ"
library = "traffic_violation_detection.dll"
[capabilities]
use_gpu = true
use_batching = true
use_tracking = true
use_zone = true
[classes]
names = ["car", "motorbike", "truck", "bus"]
defaults = ["car", "motorbike", "truck", "bus"]
[models]
# Order matters: GUI's "Models" section binds model_1 → files[0], etc.
files = [
"mbfs_vehicle_det_v4.onnx", # model_1 — Vehicle Detector
"traffic-light-det.onnx", # model_2 — Traffic Light Detector
"helmet_dt_v10.onnx", # model_3 — Helmet Detector
"lp_detection_v4.onnx", # model_4 — Plate Detector
"license_place_rec_crnn_v8.onnx", # model_5 — CRNN/CTC sequence OCR (v8)
"weight_detect_corner.onnx", # model_6 — 4-corner plate detector
"mbfsn_cls_brand_car_v1.onnx", # model_7 — Joint Make_Model classifier (80 classes, single softmax)
]
[inference]
model = "mbfs_vehicle_det_v4.onnx"
confidence = 0.5
nms = 0.45
input_size = 640
[models.traffic_light]
model = "traffic-light-det.onnx"
kind = "yolo"
input_size = 640
confidence = 0.5
nms = 0.45
[models.helmet]
model = "helmet_dt_v10.onnx"
kind = "yolo"
input_size = 640
confidence = 0.5
nms = 0.45
[models.plate_detector]
model = "lp_detection_v4.onnx"
kind = "yolo"
input_size = 640
confidence = 0.3
nms = 0.45
# CRNN/CTC sequence OCR (v8). Single model for both 1-line and 2-line plates.
# See LPR manifest for full algorithm description (corner-warp + LPTR-AFLNet).
[models.plate_ocr_crnn]
model = "license_place_rec_crnn_v8.onnx"
kind = "ocr_seq"
input_size = [128, 32] # [width, height]
[models.plate_ocr_crnn.ocr_seq]
vocab = "0123456789ABCDEFGHKLMNPRSTUVXYZ"
channels = 1 # grayscale; host applies BT.601 luma + x/255.0
# 4-corner plate corner detector (perspective rectification source).
[models.plate_corner]
model = "weight_detect_corner.onnx"
kind = "yolo"
input_size = 320
confidence = 0.3
nms = 0.5
# Joint Make_Model classifier (YOLOv8n-cls, 80 classes "{Make}_{Model}").
# Single softmax head; plugin splits label on the first '_' to recover
# brand vs model. Replaces the older two-head model (brand_logits 9 +
# model_logits 72) — same datalake schema preserved.
[models.vehicle_brand]
model = "mbfsn_cls_brand_car_v1.onnx"
kind = "classifier"
input_size = 224
# TEMP — pixel-based traffic-light classifier.
#
# Substitutes for the YOLO `traffic_light` model (which is a single-class
# "Red" detector and hallucinates red on green phases at cam 301). When a
# multi-class traffic-light model is retrained, delete this section and
# revert the `light_pixel` swap in `lib.rs` Phase B1.
#
# All defaults tuned against 227 LPR frames spanning cams 1/4/5; operators
# rarely need to touch them.
[traffic_light_pixel]
value_threshold = 130 # 0–255; min max(R,G,B) for a pixel to count as "lit"
red_margin = 60 # R - max(G,B) for a pixel to count as red
green_margin = 40 # G - max(R,B) for a pixel to count as green
yellow_margin = 50 # min(R,G) - B for a pixel to count as yellow
min_lit_fraction = 0.02 # winning color must be at least this fraction of ROI
# ── Config page schema (data-driven GUI) ──────────────────────────────────
[[config.sections]]
title = "MODELS"
fields = [
{ key = "model_1", type = "model", label = "Vehicle Detector:" },
{ key = "model_2", type = "model", label = "Light Classifier:" },
{ key = "model_3", type = "model", label = "Helmet Classifier:" },
{ key = "model_4", type = "model", label = "Plate Detector:" },
{ key = "model_5", type = "model", label = "CRNN OCR Model (v8):" },
{ key = "model_6", type = "model", label = "Corner Detector:" },
{ key = "model_7", type = "model", label = "Vehicle Brand:" },
]
[[config.sections]]
title = "DETECTION"
fields = [
{ key = "inference.confidence", type = "slider", label = "Vehicle Detection Confidence", help = "Primary YOLO vehicle detection confidence (0.0-1.0)", min = 0.0, max = 1.0, step = 0.05, default = 0.5 },
{ key = "models.traffic_light.confidence", type = "slider", label = "Traffic Light Confidence", help = "Traffic light detection confidence (0.0-1.0)", min = 0.0, max = 1.0, step = 0.05, default = 0.5 },
{ key = "models.helmet.confidence", type = "slider", label = "Helmet Detection Confidence", help = "Helmet detection confidence (0.0-1.0)", min = 0.0, max = 1.0, step = 0.05, default = 0.5 },
{ key = "models.plate_detector.confidence", type = "slider", label = "Plate Detection Confidence", help = "Plate detector confidence (0.0-1.0)", min = 0.0, max = 1.0, step = 0.05, default = 0.3 },
{ key = "two_line_aspect_max", type = "slider", label = "2-Line Plate Aspect Threshold", help = "Plates with width/height below this are tried as 2-line first. Falls back to 1-line on failed validation.", min = 1.5, max = 3.5, step = 0.1, default = 2.3 },
{ key = "lpr_min_ocr_confidence", type = "slider", label = "Min Plate OCR Confidence", help = "Reject whole plate readings below this averaged per-character confidence (0.0-1.0)", min = 0.0, max = 1.0, step = 0.05, default = 0.3 },
]
[[config.sections]]
title = "VEHICLE IDENTIFICATION"
fields = [
{ key = "vehicle_brand_enabled", type = "toggle", label = "Brand/Model Classifier", description = "Classify make and model on confirmed vehicle tracks", default = true },
{ key = "vehicle_brand_classify_interval", type = "number", label = "Classify Interval", help = "Frames between brand+model classification (1-30)", min = 1, max = 30, step = 1, default = 5, visible_when = "vehicle_brand_enabled" },
{ key = "vehicle_brand_min_confidence", type = "slider", label = "Min Brand Confidence", help = "Drop brand+model predictions below this joint-softmax confidence (80-class Make_Model head). 0.3 is a reasonable default; both brand and model receive the same confidence.", min = 0.0, max = 1.0, step = 0.05, default = 0.3, visible_when = "vehicle_brand_enabled" },
{ key = "vehicle_model_min_confidence", type = "slider", label = "Min Model Confidence", help = "Legacy knob from the two-head classifier era. The new joint Make_Model classifier uses vehicle_brand_min_confidence only; this slider is currently inert.", min = 0.0, max = 1.0, step = 0.05, default = 0.1, visible_when = "vehicle_brand_enabled" },
]
[[config.sections]]
title = "TRACKING (ByteTrack)"
fields = [
{ key = "tracking.high_conf_threshold", type = "float", label = "High Confidence", help = "High confidence threshold (0.1-1.0)", min = 0.1, max = 1.0, step = 0.05, default = 0.5 },
{ key = "tracking.low_conf_threshold", type = "float", label = "Low Confidence", help = "Low confidence threshold (0.01-0.5)", min = 0.01, max = 0.5, step = 0.01, default = 0.1 },
{ key = "tracking.confirm_frames", type = "number", label = "Confirm Frames", help = "Frames to confirm track (1-10)", min = 1, max = 10, step = 1, default = 3 },
{ key = "tracking.max_lost_frames", type = "number", label = "Max Lost Frames", help = "Frames before track is lost (1-120)", min = 1, max = 120, step = 1, default = 30 },
]
[[config.sections]]
title = "SCHEDULING"
fields = [
{ key = "light_classify_interval", type = "number", label = "Light Classify Interval", help = "Frames between traffic light classification (1-10)", min = 1, max = 10, step = 1, default = 2 },
{ key = "general_classify_interval", type = "number", label = "General Classify Interval", help = "Frames between general classification (1-10)", min = 1, max = 10, step = 1, default = 3 },
{ key = "max_trajectory_points", type = "number", label = "Max Trajectory Points", help = "Maximum trajectory history per track (10-200)", min = 10, max = 200, step = 10, default = 60 },
]
[[config.sections]]
title = "VIOLATION RULES"
# Toggles here promote to per-camera overrides: operators can enable
# red-light detection on cam 16 but not cam 17, etc. Everything else in
# the manifest stays plugin-wide (default `per_camera = false`).
per_camera = true
fields = [
# ── Red Light Running ──
{ key = "rules.red_light.enabled", type = "toggle", label = "Red Light Running", description = "Detect vehicles crossing stop line during red signal", default = true },
{ key = "rules.red_light.yellow_grace_period_ms", type = "number", label = "Yellow Grace (ms)", help = "Grace period after yellow light (0-2000)", min = 0, max = 2000, step = 100, default = 500, visible_when = "rules.red_light.enabled" },
{ key = "rules.red_light.confirm_window", type = "number", label = "Confirm Window", help = "Sliding window size (1-30)", min = 1, max = 30, step = 1, default = 5, visible_when = "rules.red_light.enabled" },
{ key = "rules.red_light.confirm_threshold", type = "number", label = "Confirm Threshold", help = "Required confirmations (1-30)", min = 1, max = 30, step = 1, default = 3, visible_when = "rules.red_light.enabled" },
# ── Wrong Lane ──
{ key = "rules.wrong_lane.enabled", type = "toggle", label = "Wrong Lane", description = "Detect vehicles driving in restricted lanes", default = true },
{ key = "rules.wrong_lane.confirm_window", type = "number", label = "Confirm Window", help = "Sliding window size (1-30)", min = 1, max = 30, step = 1, default = 5, visible_when = "rules.wrong_lane.enabled" },
{ key = "rules.wrong_lane.confirm_threshold", type = "number", label = "Confirm Threshold", help = "Required confirmations (1-30)", min = 1, max = 30, step = 1, default = 3, visible_when = "rules.wrong_lane.enabled" },
# ── Wrong Direction ──
{ key = "rules.wrong_direction.enabled", type = "toggle", label = "Wrong Direction", description = "Detect vehicles traveling against permitted direction", default = true },
{ key = "rules.wrong_direction.smoothing_window", type = "number", label = "Smoothing Window", help = "Direction smoothing window (1-30)", min = 1, max = 30, step = 1, default = 5, visible_when = "rules.wrong_direction.enabled" },
{ key = "rules.wrong_direction.confirm_window", type = "number", label = "Confirm Window", help = "Sliding window size (1-30)", min = 1, max = 30, step = 1, default = 7, visible_when = "rules.wrong_direction.enabled" },
{ key = "rules.wrong_direction.confirm_threshold", type = "number", label = "Confirm Threshold", help = "Required confirmations (1-30)", min = 1, max = 30, step = 1, default = 4, visible_when = "rules.wrong_direction.enabled" },
# ── No Helmet ──
{ key = "rules.no_helmet.enabled", type = "toggle", label = "No Helmet", description = "Detect motorcycle riders without helmets", default = true },
{ key = "rules.no_helmet.confirm_window", type = "number", label = "Confirm Window", help = "Sliding window size (1-30)", min = 1, max = 30, step = 1, default = 5, visible_when = "rules.no_helmet.enabled" },
{ key = "rules.no_helmet.confirm_threshold", type = "number", label = "Confirm Threshold", help = "Required confirmations (1-30)", min = 1, max = 30, step = 1, default = 3, visible_when = "rules.no_helmet.enabled" },
# ── Illegal U-Turn ──
{ key = "rules.illegal_uturn.enabled", type = "toggle", label = "Illegal U-Turn", description = "Detect unauthorized U-turns in restricted zones", default = true },
{ key = "rules.illegal_uturn.turn_threshold_degrees", type = "float", label = "Turn Threshold (°)", help = "Minimum heading change for U-turn (90-180)", min = 90.0, max = 180.0, step = 5.0, default = 150.0, visible_when = "rules.illegal_uturn.enabled" },
{ key = "rules.illegal_uturn.trajectory_window", type = "number", label = "Trajectory Window", help = "Frames for trajectory analysis (5-120)", min = 5, max = 120, step = 5, default = 30, visible_when = "rules.illegal_uturn.enabled" },
{ key = "rules.illegal_uturn.confirm_window", type = "number", label = "Confirm Window", help = "Sliding window size (1-30)", min = 1, max = 30, step = 1, default = 5, visible_when = "rules.illegal_uturn.enabled" },
{ key = "rules.illegal_uturn.confirm_threshold", type = "number", label = "Confirm Threshold", help = "Required confirmations (1-30)", min = 1, max = 30, step = 1, default = 3, visible_when = "rules.illegal_uturn.enabled" },
# ── Speeding ──
{ key = "rules.speeding.enabled", type = "toggle", label = "Speeding", description = "Detect vehicles exceeding speed limit (requires calibration)", default = false },
{ key = "rules.speeding.speed_limit_kmh", type = "float", label = "Speed Limit (km/h)", help = "Maximum allowed speed (10-200)", min = 10.0, max = 200.0, step = 5.0, default = 60.0, visible_when = "rules.speeding.enabled" },
{ key = "rules.speeding.measurement_window", type = "number", label = "Measurement Window", help = "Frames for speed measurement (3-60)", min = 3, max = 60, step = 1, default = 10, visible_when = "rules.speeding.enabled" },
{ key = "rules.speeding.confirm_window", type = "number", label = "Confirm Window", help = "Sliding window size (1-30)", min = 1, max = 30, step = 1, visible_when = "rules.speeding.enabled" },
{ key = "rules.speeding.confirm_threshold", type = "number", label = "Confirm Threshold", help = "Required confirmations (1-30)", min = 1, max = 30, step = 1, visible_when = "rules.speeding.enabled" },
]