问题已定位!
原帖主「通宵睡一宿」已经找到关键:需要使用相机厂家提供的准确标定参数。
完整解决方案总结
问题根源
| 问题点 | 原因 | 影响 |
|---|---|---|
| 标定参数不匹配 | 配置文件中的内参是默认值,不是自己相机的参数 | 深度计算错误 |
| 分辨率不匹配 | 配置文件是 1280x640,实际图像是 1280x720 | 图像缩放错误 |
| 命令行参数未生效 | camera_fx 等参数被配置文件覆盖 |
修改无效 |
解决步骤
# 1️⃣ 获取相机厂家的标定参数(内参 + 外参 + 畸变系数)
# 通常厂家会提供 YAML 文件或参数表格
# 2️⃣ 查看当前配置文件
cat /opt/tros/humble/share/hobot_stereonet/config/stereo.yaml
# 3️ 备份并修改配置文件
sudo cp /opt/tros/humble/share/hobot_stereonet/config/stereo.yaml \
/opt/tros/humble/share/hobot_stereonet/config/stereo.yaml.bak
sudo vim /opt/tros/humble/share/hobot_stereonet/config/stereo.yaml
配置文件修改示例
stereo0:
cam0:
intrinsics: [1775.42, 1776.80, 558.23, 410.75] # 厂家提供的 fx, fy, cx, cy
resolution: [1280, 720] # 实际图像分辨率
distortion_coeffs: [0, 0, 0, 0] # 已矫正则设为0
cam1:
intrinsics: [1775.42, 1776.80, 558.23, 410.75]
resolution: [1280, 720]
distortion_coeffs: [0, 0, 0, 0]
T_cn_cnm1: # 外参矩阵(基线信息)
- [1.0, 0.0, 0.0, -0.02535] # baseline = 25.35mm
- [0.0, 1.0, 0.0, 0.0]
- [0.0, 0.0, 1.0, 0.0]
- [0.0, 0.0, 0.0, 1.0]
验证方法
# 重新启动,观察日志第一行
ros2 launch hobot_stereonet stereonet_model_web_visual.launch.py \
stereonet_model_file_path:=/opt/tros/humble/share/hobot_stereonet/config/DStereoV2.2.bin \
use_local_image:=True \
local_image_path:=/root/stereo \
need_rectify:=False
# 确认日志输出:
# => rectified fx: 1775.42, fy: 1776.80, cx: 558.23, cy: 410.75, base_line: 0.02535
给「星辰坠入深海」的建议
如果你也遇到类似问题,按以下顺序排查:
1. 确认相机类型 → 官方模组 OR 自定义相机
2. 获取标定参数 → 官方模组从 EEPROM 读取 / 自定义相机找厂家要
3. 检查配置文件 → 内参、分辨率、畸变系数是否匹配
4. 验证日志输出 → 启动后确认参数是否正确加载
5. 测试深度效果 → 观察点云/深度图是否合理
相关社区资源
| 帖子 | 内容 |
|---|---|
| 双目模型深度估计问题 | 内参不匹配导致深度错误的案例 |
| 标定参数获取方法 | 官方模组标定参数说明 |
| 自定义相机标定 | 为自定义双目相机添加标定参数 |
有其他问题欢迎继续提问! ![]()