node-red-node-rdk-tools
Version:
配合RDK硬件及TROS使用的Node-RED功能包(Node-RED nodes for using TROS on a RDK hardware and TROS)
617 lines • 14.3 kB
JSON
[
{
"id": "mobilesam_pro_tab",
"type": "tab",
"label": "MobileSAM 分割一切",
"disabled": false,
"info": ""
},
{
"id": "group_sam_stream",
"type": "group",
"z": "mobilesam_pro_tab",
"name": "实时视频流分割",
"style": {
"fill": "#e3f3d3",
"fill-opacity": "0.6",
"label": true
},
"nodes": [
"inject_usb_sam",
"inject_mipi_sam",
"change_sam_config",
"node_execute_sam",
"inject_stop_sam",
"debug_sam_log",
"exec_init_sam"
],
"x": 114,
"y": 151.5,
"w": 992,
"h": 189.5
},
{
"id": "exec_init_sam",
"type": "exec",
"z": "tab1",
"g": "group_sam_stream",
"command": "cp -r /opt/tros/humble/lib/mono_mobilesam/config/ . || true",
"addpay": false,
"append": "",
"useSpawn": false,
"timer": "",
"oldrc": false,
"name": "初始化配置 (CP)",
"x": 640,
"y": 200,
"wires": [
[],
[],
[]
]
},
{
"id": "group_sam_photo",
"type": "group",
"z": "mobilesam_pro_tab",
"name": "📷 单帧拍照分割",
"style": {
"fill": "#fff9c4",
"fill-opacity": "0.6",
"label": true
},
"nodes": [
"inject_take_sam",
"cam_take_sam",
"exec_process_sam",
"file_read_sam",
"image_view_sam",
"debug_sam_status"
],
"x": 114,
"y": 391.5,
"w": 872,
"h": 129.5
},
{
"id": "group_viz_sam",
"type": "group",
"z": "mobilesam_pro_tab",
"name": "结果可视化",
"style": {
"fill": "#d1e7f5",
"fill-opacity": "0.6",
"label": true
},
"nodes": [
"inject_browser_sam",
"open_browser_sam",
"delay_preview_sam",
"set_ws_url_sam",
"video_preview_sam"
],
"x": 114,
"y": 579,
"w": 412,
"h": 169.5
},
{
"id": "group_env_sam",
"type": "group",
"z": "mobilesam_pro_tab",
"name": "环境准备",
"style": {
"fill": "#f3e5f5",
"fill-opacity": "0.6",
"label": true
},
"nodes": [
"inject_update_sam",
"smart_update_sam",
"change_notify_sam",
"audio_notify_sam"
],
"x": 114,
"y": 19,
"w": 832,
"h": 102
},
{
"id": "audio_notify_sam",
"type": "rdk-tools texttoaudio",
"z": "tab1",
"g": "group_env_sam",
"name": "",
"x": 850,
"y": 60,
"wires": []
},
{
"id": "inject_usb_sam",
"type": "inject",
"z": "mobilesam_pro_tab",
"g": "group_sam_stream",
"name": "启动 (USB视频流)",
"props": [
{
"p": "payload"
},
{
"p": "camera",
"v": "usb",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 250,
"y": 200,
"wires": [
[]
]
},
{
"id": "inject_mipi_sam",
"type": "inject",
"z": "mobilesam_pro_tab",
"g": "group_sam_stream",
"name": "启动 (MIPI视频流)",
"props": [
{
"p": "payload"
},
{
"p": "camera",
"v": "mipi",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 250,
"y": 240,
"wires": [
[]
]
},
{
"id": "change_sam_config",
"type": "change",
"z": "mobilesam_pro_tab",
"g": "group_sam_stream",
"name": "配置流参数",
"rules": [
{
"t": "set",
"p": "launch",
"pt": "msg",
"to": "mono_mobilesam sam.launch.py",
"tot": "str"
},
{
"t": "set",
"p": "insert",
"pt": "msg",
"to": "$join(['export CAM_TYPE=', msg.camera])",
"tot": "jsonata"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 670,
"y": 220,
"wires": [
[
"node_execute_sam"
]
]
},
{
"id": "node_execute_sam",
"type": "rdk-tools checkexecute",
"z": "mobilesam_pro_tab",
"g": "group_sam_stream",
"name": "执行分割",
"x": 840,
"y": 260,
"wires": [
[
"debug_sam_log"
],
[
"debug_sam_log"
]
]
},
{
"id": "inject_stop_sam",
"type": "inject",
"z": "mobilesam_pro_tab",
"g": "group_sam_stream",
"name": "关闭服务",
"props": [
{
"p": "kill",
"v": "",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 220,
"y": 300,
"wires": [
[
"node_execute_sam"
]
]
},
{
"id": "debug_sam_log",
"type": "debug",
"z": "mobilesam_pro_tab",
"g": "group_sam_stream",
"name": "系统日志",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1000,
"y": 260,
"wires": []
},
{
"id": "inject_take_sam",
"type": "inject",
"z": "mobilesam_pro_tab",
"g": "group_sam_photo",
"name": "点击拍照",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 220,
"y": 440,
"wires": [
[
"cam_take_sam"
]
]
},
{
"id": "cam_take_sam",
"type": "rdk-camera takephoto",
"z": "mobilesam_pro_tab",
"g": "group_sam_photo",
"cameratype": "1",
"filemode": "2",
"filename": "input.jpg",
"filedefpath": "1",
"filepath": "/root",
"fileformat": "jpeg",
"resolution": "2",
"rotation": "0",
"fliph": "0",
"flipv": "0",
"brightness": "50",
"contrast": "0",
"sharpness": "0",
"quality": "80",
"imageeffect": "none",
"exposuremode": "auto",
"iso": "0",
"agcwait": "1.0",
"led": "0",
"awb": "auto",
"name": "拍摄照片",
"x": 360,
"y": 440,
"wires": [
[
"exec_process_sam"
]
]
},
{
"id": "exec_process_sam",
"type": "exec",
"z": "mobilesam_pro_tab",
"g": "group_sam_photo",
"command": "cp -r /opt/tros/humble/lib/mono_mobilesam/config/ . 2>/dev/null; source /opt/tros/humble/setup.bash && ros2 launch mono_mobilesam sam_feedback.launch.py dnn_example_image:=input.jpg dnn_example_dump_render_img:=1 > /dev/null 2>&1 && mv render_*.jpg result_sam.jpg",
"addpay": false,
"append": "",
"useSpawn": false,
"timer": "",
"oldrc": false,
"name": "处理: 分割+重命名",
"x": 550,
"y": 440,
"wires": [
[
"file_read_sam",
"debug_sam_status"
],
[],
[]
]
},
{
"id": "file_read_sam",
"type": "file in",
"z": "mobilesam_pro_tab",
"g": "group_sam_photo",
"name": "读取结果",
"filename": "result_sam.jpg",
"format": "buffer",
"chunk": false,
"sendError": false,
"encoding": "none",
"allProps": false,
"x": 740,
"y": 440,
"wires": [
[
"image_view_sam"
]
]
},
{
"id": "image_view_sam",
"type": "image viewer",
"z": "mobilesam_pro_tab",
"g": "group_sam_photo",
"name": "显示结果",
"width": "480",
"data": "payload",
"dataType": "msg",
"active": true,
"x": 880,
"y": 440,
"wires": [
[]
]
},
{
"id": "debug_sam_status",
"type": "debug",
"z": "mobilesam_pro_tab",
"g": "group_sam_photo",
"name": "处理完成",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 740,
"y": 480,
"wires": []
},
{
"id": "inject_browser_sam",
"type": "inject",
"z": "mobilesam_pro_tab",
"g": "group_viz_sam",
"name": "打开浏览器",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "http://{host}:8000",
"payloadType": "str",
"x": 220,
"y": 620,
"wires": [
[
"open_browser_sam"
]
]
},
{
"id": "open_browser_sam",
"type": "rdk-tools openurl",
"z": "mobilesam_pro_tab",
"g": "group_viz_sam",
"name": "",
"x": 400,
"y": 620,
"wires": []
},
{
"id": "delay_preview_sam",
"type": "delay",
"z": "mobilesam_pro_tab",
"g": "group_viz_sam",
"name": "",
"pauseType": "delay",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 240,
"y": 660,
"wires": [
[
"set_ws_url_sam"
]
]
},
{
"id": "set_ws_url_sam",
"type": "change",
"z": "mobilesam_pro_tab",
"g": "group_viz_sam",
"name": "设定视频流",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "ws://{host}:8000",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 390,
"y": 660,
"wires": [
[
"video_preview_sam"
]
]
},
{
"id": "video_preview_sam",
"type": "rdk-tools videows",
"z": "mobilesam_pro_tab",
"g": "group_viz_sam",
"name": "Web预览",
"fps": "2",
"width": "640",
"active": true,
"x": 420,
"y": 700,
"wires": [
[],
[],
[]
]
},
{
"id": "inject_update_sam",
"type": "inject",
"z": "mobilesam_pro_tab",
"g": "group_env_sam",
"name": "检查更新",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 220,
"y": 80,
"wires": [
[
"smart_update_sam"
]
]
},
{
"id": "smart_update_sam",
"type": "rdk-tools smartupdate",
"z": "mobilesam_pro_tab",
"g": "group_env_sam",
"name": "",
"x": 380,
"y": 80,
"wires": [
[
"change_notify_sam"
],
[]
]
},
{
"id": "change_notify_sam",
"type": "change",
"z": "mobilesam_pro_tab",
"g": "group_env_sam",
"name": "提示内容",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "环境检查完成",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 540,
"y": 80,
"wires": [
[]
]
},
{
"id": "cf134a8e6c4ef76d",
"type": "global-config",
"env": [],
"modules": {
"node-red-node-rdk-tools": "0.0.27",
"node-red-node-rdk-camera": "0.0.17",
"node-red-contrib-image-tools": "2.1.1"
}
}
]