node-red-node-rdk-tools
Version:
配合RDK硬件及TROS使用的Node-RED功能包(Node-RED nodes for using TROS on a RDK hardware and TROS)
351 lines • 8.87 kB
JSON
[
{
"id": "dosod_simple_tab",
"type": "tab",
"label": "DOSOD 目标检测",
"info": "# DOSOD 目标检测\n\n使用系统预装的 int8 模型,检测 COCO 数据集的 80 类常见物体。\n\n## 使用方法\n1. 调整置信度阈值(可选)\n2. 点击启动检测(MIPI 或 USB)\n3. 点击打开可视化页面查看结果"
},
{
"id": "comment_score",
"type": "comment",
"z": "dosod_simple_tab",
"name": "⚙️ 置信度阈值(可选)",
"info": "默认值:0.4\n- 值越小,检测到的物体越多(可能包含误检)\n- 值越大,只显示高置信度物体(可能漏检)\n推荐范围:0.2 ~ 0.5",
"x": 150,
"y": 40,
"wires": []
},
{
"id": "inject_score",
"type": "inject",
"z": "dosod_simple_tab",
"name": "设置置信度",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"topic": "",
"payload": "0.4",
"payloadType": "str",
"x": 120,
"y": 80,
"wires": [
[
"function_save_score"
]
],
"info": "双击修改置信度值(0.1~0.5)"
},
{
"id": "function_save_score",
"type": "function",
"z": "dosod_simple_tab",
"name": "保存置信度",
"func": "var score = parseFloat(msg.payload) || 0.4;\nif (score < 0.1) score = 0.1;\nif (score > 0.5) score = 0.5;\n\nglobal.set('dosod_score_threshold', score);\n\nnode.status({\n fill: \"green\",\n shape: \"dot\",\n text: \"置信度: \" + score.toFixed(2)\n});\n\nmsg.payload = '✓ 置信度已设置为: ' + score.toFixed(2);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 320,
"y": 80,
"wires": [
[
"debug_score"
]
]
},
{
"id": "debug_score",
"type": "debug",
"z": "dosod_simple_tab",
"name": "置信度状态",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 520,
"y": 80,
"wires": []
},
{
"id": "comment_start",
"type": "comment",
"z": "dosod_simple_tab",
"name": "📷 启动检测",
"info": "",
"x": 150,
"y": 140,
"wires": []
},
{
"id": "inject_mipi",
"type": "inject",
"z": "dosod_simple_tab",
"name": "📹 MIPI摄像头",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"topic": "",
"payload": "mipi",
"payloadType": "str",
"x": 120,
"y": 180,
"wires": [
[
"function_build_cmd"
]
]
},
{
"id": "inject_usb",
"type": "inject",
"z": "dosod_simple_tab",
"name": "🎥 USB摄像头",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"topic": "",
"payload": "usb",
"payloadType": "str",
"x": 120,
"y": 220,
"wires": [
[
"function_build_cmd"
]
]
},
{
"id": "function_build_cmd",
"type": "function",
"z": "dosod_simple_tab",
"name": "构建启动命令",
"func": "var mode = msg.payload || 'usb';\nvar score = global.get('dosod_score_threshold') || 0.4;\n\n// 构建命令:bash start_dosod.sh <mode> <score>\nmsg.payload = mode + ' ' + score;\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 320,
"y": 200,
"wires": [
[
"exec_start"
]
]
},
{
"id": "exec_start",
"type": "exec",
"z": "dosod_simple_tab",
"command": "stdbuf -oL -eL bash /home/sunrise/.dosod_config/start_dosod.sh",
"addpay": true,
"append": "",
"useSpawn": true,
"timer": "0",
"oldrc": false,
"name": "启动检测",
"x": 520,
"y": 200,
"wires": [
[
"debug_output"
],
[
"debug_error"
],
[]
]
},
{
"id": "debug_output",
"type": "debug",
"z": "dosod_simple_tab",
"name": "启动输出",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 720,
"y": 180,
"wires": []
},
{
"id": "debug_error",
"type": "debug",
"z": "dosod_simple_tab",
"name": "启动错误",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 720,
"y": 220,
"wires": []
},
{
"id": "comment_view",
"type": "comment",
"z": "dosod_simple_tab",
"name": "👁️ 查看结果",
"info": "",
"x": 150,
"y": 280,
"wires": []
},
{
"id": "inject_browser",
"type": "inject",
"z": "dosod_simple_tab",
"name": "打开可视化页面",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 120,
"y": 320,
"wires": [
[
"function_get_url"
]
]
},
{
"id": "function_get_url",
"type": "function",
"z": "dosod_simple_tab",
"name": "获取URL",
"func": "msg.payload = 'http://{host}:8000';\n\nnode.status({\n fill: \"blue\",\n shape: \"dot\",\n text: \"Opening: \" + msg.payload\n});\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 320,
"y": 320,
"wires": [
[
"openurl"
]
]
},
{
"id": "openurl",
"type": "rdk-tools openurl",
"z": "dosod_simple_tab",
"name": "打开浏览器",
"x": 520,
"y": 320,
"wires": []
},
{
"id": "comment_stop",
"type": "comment",
"z": "dosod_simple_tab",
"name": "⏹️ 停止服务",
"info": "",
"x": 150,
"y": 360,
"wires": []
},
{
"id": "inject_stop",
"type": "inject",
"z": "dosod_simple_tab",
"name": "停止所有服务",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 120,
"y": 400,
"wires": [
[
"exec_stop"
]
]
},
{
"id": "exec_stop",
"type": "exec",
"z": "dosod_simple_tab",
"command": "pkill -f hobot_dosod && pkill -f websocket && sudo pkill -9 nginx 2>/dev/null || true && echo '✓ 所有DOSOD服务已停止'",
"addpay": false,
"append": "",
"useSpawn": false,
"timer": "10",
"oldrc": false,
"name": "停止服务",
"x": 320,
"y": 400,
"wires": [
[
"debug_stop"
],
[],
[]
]
},
{
"id": "debug_stop",
"type": "debug",
"z": "dosod_simple_tab",
"name": "停止状态",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 520,
"y": 400,
"wires": []
},
{
"id": "6fd56306711aa06f",
"type": "global-config",
"env": [],
"modules": {
"node-red-node-rdk-tools": "0.0.27"
}
}
]