问题定位:标定文件格式 + 分辨率不匹配
从你提供的标定文件看,格式缺少 StereoNet v2.4 需要的关键字段,且分辨率配置可能不匹配。
完整解决方案
步骤 1:修改标定文件格式(关键)
当前标定文件缺少 baseline 和 projection 字段,StereoNet 无法解析。参考 SC230ai 格式创建兼容文件:
# 1. 备份原文件
cp /opt/tros/humble/lib/mipi_cam/config/SC132gs_dual_calibration.yaml \
/opt/tros/humble/lib/mipi_cam/config/SC132gs_dual_calibration.yaml.bak
# 2. 创建兼容格式的标定文件
cat > /opt/tros/humble/lib/mipi_cam/config/SC132gs_dual_calibration.yaml << 'EOF'
%YAML:1.0
image_width: 1280
image_height: 1088
camera_matrix_1: !!opencv-matrix
rows: 3
cols: 3
dt: d
data: [528.6953213954334, 0, 621.6598968327049, 0, 469.7443489102585, 344.7801912987854, 0, 0, 1]
distortion_1: !!opencv-matrix
rows: 1
cols: 8
dt: d
data: [-0.19022404784416216, 0.08737900971037368, -0.00013633102684873613, 2.8387028454768084e-05, 0.037123187744979025, 0.1798687498557986, -0.06820294642386052, 0.10684527621059339]
camera_matrix_2: !!opencv-matrix
rows: 3
cols: 3
dt: d
data: [529.2760196145524, 0, 654.6320151265384, 0, 470.4236596788936, 318.0571160826385, 0, 0, 1]
distortion_2: !!opencv-matrix
rows: 1
cols: 8
dt: d
data: [-0.08168737119014227, 0.051348177058130356, 0.00010479656330654928, -8.819143676712554e-06, 0.024544736926599094, 0.28711736495579887, -0.06268635878956813, 0.07182651571052037]
rectification_1: !!opencv-matrix
rows: 3
cols: 3
dt: d
data: [1, 0, 0, 0, 1, 0, 0, 0, 1]
rectification_2: !!opencv-matrix
rows: 3
cols: 3
dt: d
data: [1, 0, 0, 0, 1, 0, 0, 0, 1]
projection_1: !!opencv-matrix
rows: 3
cols: 4
dt: d
data: [528.6953213954334, 0, 621.6598968327049, 0, 0, 469.7443489102585, 344.7801912987854, 0, 0, 0, 1, 0]
projection_2: !!opencv-matrix
rows: 3
cols: 4
dt: d
data: [529.2760196145524, 0, 654.6320151265384, -36.9, 0, 470.4236596788936, 318.0571160826385, 0, 0, 0, 1, 0]
baseline: 0.0698
EOF
步骤 2:确认分辨率配置匹配
从你的配置截图看:
mipi_image_width=640,mipi_image_height=352(StereoNet 模型输入)- 标定文件
image_width: 1280,image_height: 1088(原始相机分辨率)
这个配置是正确的,StereoNet 会自动缩放。但需要确认 GDC 裁剪配置:
# 检查 run_stereo.sh 中的裁剪配置
grep -E "sub_image|image_width|image_height" run_stereo.sh | head -10
步骤 3:重新运行并捕获完整日志
# 1. 清理进程
killall stereonet_model_node mipi_cam hobot_codec_republish websocket 2>/dev/null
sleep 3
# 2. 重新运行
cd /userdata/data/test/
bash run_stereo.sh --stereonet_version v2.4 2>&1 | tee stereo_final.log
# 3. 等待 30 秒后按 Ctrl+C
步骤 4:验证深度输出
# 新开终端检查
ros2 topic list | grep -E "depth|stereo"
ros2 topic hz /StereoNetNode/stereonet_depth
# 查看深度数据
ros2 topic echo /StereoNetNode/stereonet_depth --once
如果问题依旧:查看崩溃日志
# 1. 查看 StereoNet 初始化日志
grep -A30 "init StereoNetNode" stereo_final.log
# 2. 查看标定文件加载信息
grep -i "calib\|camera_info" stereo_final.log | tail -20
# 3. 查看崩溃原因
grep -E "ERROR|died|segmentation|invalid" stereo_final.log | tail -20
配置检查清单
| 参数 | 当前值 | 要求 |
|---|---|---|
use_mipi_cam |
False |
|
calib_method |
custom |
|
stereo_calib_file_path |
绝对路径 | |
render_type |
"distance" |
|
| 标定文件格式 | 需包含 baseline/projection | ️ 需更新 |
相关参考
- 132GS MIPI 双目相机如何自行标定 - 标定文件格式详解
- 基于官方 132GS MIPI 双目相机运行双目 Demo 报错 - 同类问题完整解决
优先执行步骤 1(更新标定文件格式),然后重新运行测试。把新的日志输出(特别是 init StereoNetNode 后的内容和任何 ERROR)补充到帖子,可以帮你精准定位最后的问题!