UNPKG

node-red-node-rdk-tools

Version:

配合RDK硬件及TROS使用的Node-RED功能包(Node-RED nodes for using TROS on a RDK hardware and TROS)

278 lines (276 loc) 10.5 kB
[ { "id": "pose_detection_tab", "type": "tab", "label": "姿态检测 (Pose Detection)", "info": "# 姿态检测应用示例 (Pose Detection)\n\n**功能说明**:基于mono2d_body_detection的姿态检测,支持MIPI和USB摄像头实时检测\n\n**参考示例**:本示例参考\"人脸年龄检测\"的配置方式\n\n## 🎯 快速开始\n\n### 使用流程\n1. **选择摄像头类型**:根据硬件选择MIPI或USB摄像头\n2. **启动检测服务**:点击对应的启动按钮\n3. **查看视频流**:点击\"打开可视化页面\"在浏览器中查看实时检测画面\n4. **停止服务**:完成后点击\"停止所有服务\"\n\n## 支持平台\n- RDK X3 / X5 / S100\n- TROS Humble\n\n## 核心功能\n- 人体检测\n- 姿态检测\n- 实时监控\n\n## 核心通信配置\n\n### WebSocket视频流\n- **视频流地址**: `http://{host}:8000`\n- **图像Topic**: `/image` (JPEG编码的图像流)\n- **检测结果Topic**: 由launch文件配置\n- **性能**: 实时检测,延迟低\n\n## 参数说明\n- **配置文件**:从`/opt/tros/${TROS_DISTRO}/lib/mono2d_body_detection/config/`拷贝\n- **Launch文件**:`hobot_falldown_detection/hobot_falldown_detection.launch.py`\n- **可视化地址**:http://{host}:8000(WebSocket视频流)\n\n## 📝 手动执行命令(参考)\n\n### 使用MIPI摄像头\n```bash\n# 配置tros.b环境\nsource /opt/tros/humble/setup.bash\n\n# 设置TROS_DISTRO变量(重要!)\nexport TROS_DISTRO=humble\n\n# 从tros.b的安装路径中拷贝出运行示例需要的配置文件\ncp -r /opt/tros/${TROS_DISTRO}/lib/mono2d_body_detection/config/ .\n\n# 配置MIPI摄像头\nexport CAM_TYPE=mipi\n\n# 启动launch文件\nros2 launch hobot_falldown_detection hobot_falldown_detection.launch.py\n```\n\n### 使用USB摄像头\n```bash\n# 配置tros.b环境\nsource /opt/tros/humble/setup.bash\n\n# 设置TROS_DISTRO变量(重要!)\nexport TROS_DISTRO=humble\n\n# 从tros.b的安装路径中拷贝出运行示例需要的配置文件\ncp -r /opt/tros/${TROS_DISTRO}/lib/mono2d_body_detection/config/ .\n\n# 配置USB摄像头\nexport CAM_TYPE=usb\n\n# 启动launch文件\nros2 launch hobot_falldown_detection hobot_falldown_detection.launch.py\n```\n\n**⚠️ 注意**:使用 `${TROS_DISTRO}` 变量前必须先设置 `export TROS_DISTRO=humble`,否则命令会失败!" }, { "id": "comment_camera_section", "type": "comment", "z": "pose_detection_tab", "name": "1️⃣ 选择摄像头类型", "info": "根据您的硬件选择相应的检测方式", "x": 200, "y": 40, "wires": [] }, { "id": "comment_mipi_section", "type": "comment", "z": "pose_detection_tab", "name": "📷 MIPI摄像头检测", "info": "使用MIPI摄像头进行实时姿态检测", "x": 180, "y": 80, "wires": [] }, { "id": "inject_mipi_start", "type": "inject", "z": "pose_detection_tab", "name": "MIPI摄像头检测", "props": [ {"p": "payload"}, {"p": "topic", "vt": "str"} ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "mipi_detection", "payload": "start", "payloadType": "str", "x": 140, "y": 120, "wires": [["exec_mipi_detection"]] }, { "id": "exec_mipi_detection", "type": "exec", "z": "pose_detection_tab", "name": "MIPI检测启动器", "command": "cd /tmp && if [ -f /opt/tros/humble/setup.bash ]; then source /opt/tros/humble/setup.bash && TROS_DISTRO=humble; else echo '错误:未找到TROS安装路径' && exit 1; fi && cp -r /opt/tros/${TROS_DISTRO}/lib/mono2d_body_detection/config/ . 2>/dev/null || true && export CAM_TYPE=mipi && echo \"=== 启动MIPI摄像头姿态检测 (TROS_DISTRO=${TROS_DISTRO}) ===\" && ros2 launch hobot_falldown_detection hobot_falldown_detection.launch.py", "addpay": false, "append": "", "useSpawn": false, "timer": "120", "oldrc": false, "x": 380, "y": 120, "wires": [["debug_mipi_output"], ["debug_mipi_error"], []] }, { "id": "comment_usb_section", "type": "comment", "z": "pose_detection_tab", "name": "📷 USB摄像头检测", "info": "使用USB摄像头进行实时姿态检测", "x": 180, "y": 160, "wires": [] }, { "id": "inject_usb_start", "type": "inject", "z": "pose_detection_tab", "name": "USB摄像头检测", "props": [ {"p": "payload"}, {"p": "topic", "vt": "str"} ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "usb_detection", "payload": "start", "payloadType": "str", "x": 140, "y": 200, "wires": [["exec_usb_detection"]] }, { "id": "exec_usb_detection", "type": "exec", "z": "pose_detection_tab", "name": "USB检测启动器", "command": "cd /tmp && if [ -f /opt/tros/humble/setup.bash ]; then source /opt/tros/humble/setup.bash && TROS_DISTRO=humble; else echo '错误:未找到TROS安装路径' && exit 1; fi && cp -r /opt/tros/${TROS_DISTRO}/lib/mono2d_body_detection/config/ . 2>/dev/null || true && export CAM_TYPE=usb && echo \"=== 启动USB摄像头姿态检测 (TROS_DISTRO=${TROS_DISTRO}) ===\" && ros2 launch hobot_falldown_detection hobot_falldown_detection.launch.py", "addpay": false, "append": "", "useSpawn": false, "timer": "120", "oldrc": false, "x": 380, "y": 200, "wires": [["debug_usb_output"], ["debug_usb_error"], []] }, { "id": "comment_browser_section", "type": "comment", "z": "pose_detection_tab", "name": "2️⃣ 查看检测结果", "info": "在浏览器中查看实时检测画面", "x": 200, "y": 240, "wires": [] }, { "id": "inject_browser", "type": "inject", "z": "pose_detection_tab", "name": "打开可视化页面", "props": [ {"p": "payload"}, {"p": "topic", "vt": "str"} ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "http://{host}:8000", "payloadType": "str", "x": 140, "y": 280, "wires": [["openurl_browser"]] }, { "id": "openurl_browser", "type": "rdk-tools openurl", "z": "pose_detection_tab", "name": "", "x": 380, "y": 280, "wires": [] }, { "id": "comment_stop_section", "type": "comment", "z": "pose_detection_tab", "name": "3️⃣ 停止服务", "info": "停止所有检测相关服务", "x": 200, "y": 320, "wires": [] }, { "id": "inject_stop", "type": "inject", "z": "pose_detection_tab", "name": "停止所有服务", "props": [ {"p": "payload"}, {"p": "topic", "vt": "str"} ], "repeat": "", "crontab": "", "once": false, "topic": "stop", "payload": "stop", "payloadType": "str", "x": 140, "y": 360, "wires": [["exec_stop_all"]] }, { "id": "exec_stop_all", "type": "exec", "z": "pose_detection_tab", "name": "停止所有服务", "command": "sudo pkill -9 -f hobot_usb_cam; sudo pkill -9 -f hobot_falldown_detection; sudo pkill -9 -f hobot_codec_republish; sudo pkill -9 -f websocket; sudo pkill -9 -f python3; sudo pkill -9 -f 'ros2 launch'; sudo pkill -9 -f 'ros2 run'; sleep 2; sudo rm -rf /dev/shm/*; ros2 daemon stop 2>/dev/null; sleep 1; echo '✓ 服务已彻底停止,资源已释放'", "addpay": false, "append": "", "useSpawn": false, "timer": "10", "oldrc": false, "x": 380, "y": 360, "wires": [["debug_stop_info"], [], []] }, { "id": "debug_mipi_output", "type": "debug", "z": "pose_detection_tab", "name": "MIPI检测输出", "active": true, "tosidebar": true, "console": false, "tostatus": true, "complete": "payload", "targetType": "msg", "statusVal": "payload", "statusType": "auto", "x": 650, "y": 100, "wires": [] }, { "id": "debug_mipi_error", "type": "debug", "z": "pose_detection_tab", "name": "MIPI错误信息", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 650, "y": 140, "wires": [] }, { "id": "debug_usb_output", "type": "debug", "z": "pose_detection_tab", "name": "USB检测输出", "active": true, "tosidebar": true, "console": false, "tostatus": true, "complete": "payload", "targetType": "msg", "statusVal": "payload", "statusType": "auto", "x": 650, "y": 180, "wires": [] }, { "id": "debug_usb_error", "type": "debug", "z": "pose_detection_tab", "name": "USB错误信息", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 650, "y": 220, "wires": [] }, { "id": "debug_stop_info", "type": "debug", "z": "pose_detection_tab", "name": "停止服务状态", "active": true, "tosidebar": true, "console": false, "tostatus": true, "complete": "payload", "targetType": "msg", "statusVal": "payload", "statusType": "auto", "x": 640, "y": 360, "wires": [] } ]