RDK-X5 双目深度算法hobot_stereonet精度差

关键信息更新:分辨率 1088×1280

这个信息很重要!重新分析你的问题:


参数对应关系分析

原始标定参数(1280×1088)

从社区其他 SC132GS 用户日志:

fx_original ≈ 688
fy_original ≈ 688
cx_original ≈ 640
cy_original ≈ 544
baseline ≈ 0.079m

StereoNet 接收到的参数(你的日志)

fx = 304.31
fy = 304.31
cx = 297.57
cy = 185.25
baseline = 0.069816

问题定位

参数 理论值 (640×352) 你的实际值 偏差
fx 688×(640/1280)=344 304 -12%
cx 640/2=320 297.57 -7%
cy 352/2=176 185.25 +5%
baseline 0.079 0.0698 -12%

结论:StereoNet 实际接收的是缩放后的参数(对应 640×352),但参数值计算有误。


深度误差计算验证

深度公式:depth = (baseline × fx) / disparity

你的参数组合导致的误差:

理论值:baseline=0.079, fx=344
实际值:baseline=0.0698, fx=304

误差比例 = (0.079×344) / (0.0698×304) = 27.18 / 21.22 = 1.28

这与你实测的误差比例 1.24(77cm/62cm)基本吻合!


解决方案

方案 1:手动校正 stereo.yaml(推荐)

# 1. 找到配置文件
sudo vim /opt/tros/humble/share/hobot_stereonet/config/stereo.yaml

# 2. 修改参数(基于 640×352 输入分辨率)
baseline: 0.079      # 使用实测值
fx: 344.0            # 688 * (640/1280)
fy: 344.0
cx: 320.0            # 640 / 2
cy: 176.0            # 352 / 2

# 3. 保存后重启节点
ros2 node kill /stereonet_model_node
ros2 launch hobot_stereonet hobot_stereonet.launch.py

方案 2:检查 mipi_cam 参数传递

# 查看 mipi_cam 的标定文件
cat /opt/tros/humble/lib/mipi_cam/config/calib_params.yaml

# 检查是否有分辨率缩放配置
grep -r "640\|352" /opt/tros/humble/lib/mipi_cam/config/

方案 3:确认 StereoNet 实际输入分辨率

# 查看 StereoNet 节点日志,确认输入图像尺寸
ros2 launch hobot_stereonet hobot_stereonet.launch.py 2>&1 | grep -i "image\|resolution\|width\|height"

快速验证脚本

# 测试深度准确性
import rclpy
from rclpy.node import Node
from sensor_msgs.msg import Image
import numpy as np

class DepthTest(Node):
    def __init__(self):
        super().__init__('depth_test')
        self.sub = self.create_subscription(Image, '/depth/image_raw', self.callback, 10)
    
    def callback(self, msg):
        depth_data = np.frombuffer(msg.data, dtype=np.uint16).reshape(msg.height, msg.width)
        h, w = depth_data.shape
        # 读取中心区域深度
        center = depth_data[h//2-10:h//2+10, w//2-10:w//2+10]
        avg_depth = np.mean(center) / 1000.0
        self.get_logger().info(f'中心深度:{avg_depth:.3f}m')

rclpy.init()
node = DepthTest()
rclpy.spin_once(node, timeout_sec=2)
node.destroy_node()

预期效果

校正后在 0.6m~2m 范围:

距离 校正前误差 校正后预期
0.6m ±15cm ±3-5cm
1.0m ±20cm ±5-8cm
2.0m ±30cm ±10-15cm

请补充到原帖

修改参数后,请反馈:

  1. 修改后的 stereo.yaml 内容
  2. 0.6m/1.0m/2.0m 三点的实测对比
  3. StereoNet 启动日志中的参数行

如果校正后仍有问题,可能是 GDC 模块的参数传递 bug,需要官方技术支持介入。

相关参考: