SC132GS RDK S100 完整标定文件
根据你提供的相机参数,创建符合 StereoNet v2.4 S100 要求的标定文件:
步骤 1:创建标定文件
# 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.0, 621.6598968327049,
0.0, 469.7443489102585, 344.7801912987854,
0.0, 0.0, 1.0]
# 左目畸变系数
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.0, 654.6320151265384,
0.0, 470.4236596788936, 318.0571160826385,
0.0, 0.0, 1.0]
# 右目畸变系数
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, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]
rectification_2: !!opencv-matrix
rows: 3
cols: 3
dt: d
data: [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]
# 投影矩阵
projection_1: !!opencv-matrix
rows: 3
cols: 4
dt: d
data: [528.6953213954334, 0.0, 621.6598968327049, 0.0,
0.0, 469.7443489102585, 344.7801912987854, 0.0,
0.0, 0.0, 1.0, 0.0]
projection_2: !!opencv-matrix
rows: 3
cols: 4
dt: d
data: [529.2760196145524, 0.0, 654.6320151265384, -36.9036,
0.0, 470.4236596788936, 318.0571160826385, 0.0,
0.0, 0.0, 1.0, 0.0]
# 基线距离(米)
baseline: 0.06981825961809152
EOF
步骤 2:确认 run_stereo.sh 配置
vim /userdata/data/test/run_stereo.sh
确保以下配置(约 35-60 行):
use_mipi_cam=False
calib_method="custom"
stereo_calib_file_path="/opt/tros/humble/lib/mipi_cam/config/SC132gs_dual_calibration.yaml"
render_type="distance"
步骤 3:运行测试
# 1. 清理残留进程
killall mipi_cam stereonet_model_node hobot_codec_republish websocket 2>/dev/null
sleep 3
# 2. 启动相机节点
bash run_cam.sh --rotation 90.0 --log_level INFO &
# 3. 等待 5 秒后启动 StereoNet
sleep 5
cd /userdata/data/test/
bash run_stereo.sh --stereonet_version v2.4 2>&1 | tee stereo_test.log
步骤 4:验证深度输出
# 新开终端检查话题
ros2 topic list | grep -E "depth|stereo"
# 检查深度数据频率
ros2 topic hz /StereoNetNode/stereonet_depth
# 查看深度数据
ros2 topic echo /StereoNetNode/stereonet_depth --once
预期输出:
/StereoNetNode/stereonet_depth
/StereoNetNode/stereonet_pointcloud2
/StereoNetNode/rectify_left_image
/StereoNetNode/rectify_right_image
步骤 5:查看深度可视化
# 浏览器访问(替换为你的板子 IP)
http://<你的板子IP>:8000
标定文件关键字段说明
| 字段 | 说明 | 值来源 |
|---|---|---|
camera_matrix_1/2 |
左右目内参矩阵 | 你提供的原始标定数据 |
distortion_1/2 |
畸变系数(8 参数) | 你提供的原始标定数据 |
baseline |
基线距离 | 从 T 向量计算:0.0698m |
projection_2 |
右目投影矩阵 | 第 4 列 = -baseline × fx ≈ -36.9 |
rectification_1/2 |
校正矩阵 | 单位矩阵(假设已校正) |
如果仍有问题
# 1. 查看 StereoNet 初始化日志
grep -A30 "init StereoNetNode" stereo_test.log
# 2. 检查标定文件加载
grep -i "calib\|baseline\|custom" stereo_test.log | tail -10
# 3. 检查节点是否崩溃
grep -E "ERROR|died|segmentation" stereo_test.log | tail -20
相关参考
执行后把新的日志输出补充到帖子,特别是:
ros2 topic hz /StereoNetNode/stereonet_depth的输出grep -A30 "init StereoNetNode" stereo_test.log的输出
这样可以确认深度算法是否正常运行!