update,生成agent批处理,生成默认配置,可恢复版本
Some checks are pending
CI / host-build (push) Waiting to run
CI / rk3588-cross-build (push) Waiting to run

This commit is contained in:
sladro 2026-01-11 16:04:43 +08:00
parent ce8ae2b448
commit 97b76f45cb
4 changed files with 254 additions and 4 deletions

Binary file not shown.

54
agent/build_rk3588.bat Normal file
View File

@ -0,0 +1,54 @@
@echo off
setlocal enabledelayedexpansion
REM Build rk3588-agent for RK3588 board (Linux arm64) from Windows.
set "SCRIPT_DIR=%~dp0"
pushd "%SCRIPT_DIR%" >nul
where go >nul 2>nul
if errorlevel 1 (
echo [ERR] go not found in PATH.
popd >nul
exit /b 1
)
set "GOOS=linux"
set "GOARCH=arm64"
set "CGO_ENABLED=0"
set "VERSION=%~1"
if "%VERSION%"=="" set "VERSION=0.0.0-dev"
set "GITSHA=unknown"
for /f %%i in ('git rev-parse --short HEAD 2^>nul') do set "GITSHA=%%i"
set "OUTDIR=%SCRIPT_DIR%build"
if not exist "%OUTDIR%" mkdir "%OUTDIR%" >nul
set "OUT=%OUTDIR%\rk3588-agent_linux_arm64"
if not "%~2"=="" set "OUT=%OUTDIR%\%~2"
set "LDFLAGS=-s -w -X main.Version=%VERSION% -X main.GitSHA=%GITSHA%"
echo Building: %OUT%
echo GOOS=%GOOS% GOARCH=%GOARCH% CGO_ENABLED=%CGO_ENABLED%
echo Version=%VERSION% GitSHA=%GITSHA%
go mod download
if errorlevel 1 (
echo [ERR] go mod download failed.
popd >nul
exit /b 1
)
go build -trimpath -ldflags "%LDFLAGS%" -o "%OUT%" .\cmd\rk3588-agent
if errorlevel 1 (
echo [ERR] go build failed.
popd >nul
exit /b 1
)
echo [OK] %OUT%
popd >nul
endlocal

189
configs/sample_cam1.json Normal file
View File

@ -0,0 +1,189 @@
{
"queue": { "size": 8, "strategy": "drop_oldest" },
"graphs": [
{
"name": "cam1_sample_full_pipeline",
"nodes": [
{
"id": "in_cam1",
"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_cam1",
"type": "preprocess",
"role": "filter",
"enable": true,
"dst_w": 640,
"dst_h": 640,
"dst_format": "rgb",
"keep_ratio": false,
"use_rga": true
},
{
"id": "yolo_cam1",
"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_cam1",
"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_cam1",
"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": "osd_cam1",
"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_cam1",
"type": "preprocess",
"role": "filter",
"enable": true,
"dst_w": 1280,
"dst_h": 720,
"dst_format": "nv12",
"keep_ratio": false,
"use_rga": true
},
{
"id": "pub_cam1",
"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/cam1" },
{ "proto": "hls", "path": "./web/hls/cam1/index.m3u8", "segment_sec": 2 }
]
},
{
"id": "alarm_cam1",
"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_cam1", "pre_cam1"],
["pre_cam1", "yolo_cam1"],
["yolo_cam1", "face_det_cam1"],
["face_det_cam1", "face_recog_cam1"],
["face_recog_cam1", "osd_cam1"],
["osd_cam1", "post_cam1"],
["post_cam1", "pub_cam1"],
["pub_cam1", "alarm_cam1"]
]
}
]
}

View File

@ -43,7 +43,14 @@ python build_gallery.py --dataset "D:\App\python\AddFaceTo3588\faces\dataset" --
编译
cd /d D:\App\C++\Rk3588Sys\agent
set GOOS=windows
set GOARCH=amd64
set CGO_ENABLED=0
go build -o ".\rk3588-agent.exe" ".\cmd\rk3588-agent"
$env:GOOS="linux"
$env:GOARCH="arm64"
$env:CGO_ENABLED="0"
$VERSION="0.0.0-dev"
$GITSHA="dev"
go build -trimpath -buildvcs=false -ldflags "-s -w -X main.Version=$VERSION -X main.GitSHA=$GITSHA" -o ".\rk3588-agent" ".\cmd\rk3588-agent"
go version -m .\rk3588-agent
ls -l ./rk3588-agent_linux_arm64
chmod +x ./rk3588-agent_linux_arm64
./rk3588-agent_linux_arm64 --config agent_cam1.config.json