人脸年龄检测
功能介绍
人脸年龄检测示例订阅图片和包含人脸框信息的智能 msg,利用 BPU 进行算法推理,发布包含年龄信息的算法 msg。
代码仓库:(https://github.com/D-Robotics/face_age_detection)
支持平台
| 平台 | 运行方式 | 示例功能 |
|---|---|---|
| RDK X3, RDK X3 Module | Ubuntu 22.04 (Humble) | 启动 MIPI/USB 摄像头,并通过 Web 展示推理渲染结果 |
| RDK X5, RDK X5 Module | Ubuntu 22.04 (Humble) | 启动 MIPI/USB 摄像头,并通过 Web 展示推理渲染结果 |
算法信息
| 模型 | 平 台 | 输入尺寸 | 推理帧率(fps) |
|---|---|---|---|
| faceAge | X3 | 1×3×128x128 | 1261.29 |
| 模型 | 平台 | 输入尺寸 | 推理帧率(fps) |
|---|---|---|---|
| faceAge | X5 | 1×3×128x128 | 1207.32 |
准备工作
RDK 平台
-
RDK 已烧录好 RDK OS 系统。
-
RDK 已成功安装 TogetheROS.Bot。
-
RDK 已安装 MIPI 或者 USB 摄像头。
-
确认 PC 机能够通过网络访问 RDK。
使用介绍
人脸年龄检测(face_age_detection)package订阅 sensor package 发布的图片以及人体检测和跟踪 package 发布的人脸框检测结果 ,经过推理后发布算法 msg,通过 websocket package 实现在 PC 端浏览器上渲染显示发布的图片和对应的算法结果。
使用 MIPI 摄像头发布图片
- Foxy
- Humble
# 配置tros.b环境
source /opt/tros/setup.bash
# 配置tros.b环境
source /opt/tros/humble/setup.bash
# 从tros.b的安装路径中拷贝出运行示例需要的配置文件。
cp -r /opt/tros/${TROS_DISTRO}/lib/mono2d_body_detection/config/ .
# 配置MIPI摄像头
export CAM_TYPE=mipi
# 启动launch文件
ros2 launch face_age_detection body_det_face_age_det.launch.py
使用 USB 摄像头发布图片
- Foxy
- Humble
# 配置tros.b环境
source /opt/tros/setup.bash
# 配置tros.b环境
source /opt/tros/humble/setup.bash
# 从tros.b的安装路径中拷贝出运行示例需要的配置文件。
cp -r /opt/tros/${TROS_DISTRO}/lib/mono2d_body_detection/config/ .
# 配置USB摄像头
export CAM_TYPE=usb
# 启动launch文件
ros2 launch face_age_detection body_det_face_age_det.launch.py
结果分析
在运行终端输出如下信息:
[mono2d_body_detection-3] [WARN] [1731986598.310822365] [example]: This is mono2d body det example!
[face_age_detection-5] [WARN] [1731986598.405068602] [face_age_det_node]: => face_age_det_node params:
[face_age_detection-5] => feed_type: 0
[face_age_detection-5] => is_sync_mode: 0
[face_age_detection-5] => model_file_name: /root/zhikang.zeng/work_humble_ws_x5/tros_ws/install/share/face_age_detection/config/faceAge.hbm
[face_age_detection-5] => is_shared_mem_sub: 1
[face_age_detection-5] => dump_render_img: 0
[face_age_detection-5] => ai_msg_pub_topic_name: /hobot_face_age_detection
[face_age_detection-5] => max_slide_window_size: 30
[face_age_detection-5] [INFO] [1731986598.406117839] [dnn]: Node init.
[face_age_detection-5] [INFO] [1731986598.406189046] [face_age_det_node]: => Set node para.
[face_age_detection-5] [INFO] [1731986598.406316544] [dnn]: Model init.
[mono2d_body_detection-3] [WARN] [1731986598.408599348] [mono2d_body_det]: Parameter:
[mono2d_body_detection-3] is_sync_mode_: 0
[mono2d_body_detection-3] model_file_name_: config/multitask_body_head_face_hand_kps_960x544.hbm
[mono2d_body_detection-3] is_shared_mem_sub: 1
[mono2d_body_detection-3] ai_msg_pub_topic_name: /hobot_mono2d_body_detection
[mono2d_body_detection-3] ros_img_topic_name: /image_raw
[mono2d_body_detection-3] image_gap: 1
[mono2d_body_detection-3] [BPU_PLAT]BPU Platform Version(1.3.6)!
[mono2d_body_detection-3] [HBRT] set log level as 0. version = 3.15.54.0
[mono2d_body_detection-3] [DNN] Runtime version = 1.23.10_(3.15.54 HBRT)
[face_age_detection-5] [BPU_PLAT]BPU Platform Version(1.3.6)!
[face_age_detection-5] [HBRT] set log level as 0. version = 3.15.54.0
[face_age_detection-5] [DNN] Runtime version = 1.23.10_(3.15.54 HBRT)
输出 log 显示,程序运行成功,推理时算法输入和输出帧率为 30fps,每秒钟刷新一次统计帧率。
在 PC 端的浏览器输入 http://IP:8000 即可查看图像和算法渲染效果(IP 为 RDK 的 IP 地址):
