# 使用说明 ## 点云到 CAD 配准 脚本先用前端/后端质心估计初始平移,再默认执行刚体 ICP 精配准,进一步修正旋转和平移。 ## 常用命令 ```powershell python translate_align_pointcloud_to_cad.py --no_visualize ``` 如果只想使用旧的纯平移方法: ```powershell python translate_align_pointcloud_to_cad.py --no_visualize --no_icp ``` ## 主要参数 - `--cad`: STEP CAD 文件路径,默认 `datasets/CAD/*****.stp`。 - `--pointcloud`: 待配准 PLY 点云或点云目录,默认 `datasets/shift_test_output/`。传目录时会优先读取 `shifted_whole_pointcloud.ply`。 - `--output_dir`: 输出目录,默认 `results`。 - `--axis`: 前后方向轴,默认 `x`。 - `--crop_ratio`: 前端/后端裁剪比例,默认 `0.01`。 - `--cad_sample_points`: CAD mesh 采样点数,默认 `30000`。 - `--local_sample_points`: 前端/后端质心计算采样点数,默认 `1000`。 - `--scale_pointcloud`: 点云缩放系数。例如点云是米、CAD 是毫米时设为 `1000`。 - `--no_visualize`: 不显示 Open3D 可视化窗口。 ## ICP 参数 - `--no_icp`: 跳过 ICP,只做前后端质心平移。 - `--icp_sample_points`: 用于 ICP 的源点云抽样点数,默认 `200000`。 - `--icp_voxel_size`: ICP 前的体素降采样尺寸,默认 `0` 表示不降采样。 - `--icp_max_correspondence_distance`: ICP 最大对应距离,默认 `0` 表示根据初始误差自动估计。 - `--icp_max_iteration`: ICP 最大迭代次数,默认 `50`。 ## 误差统计 - `--error_sample_points`: 配准误差统计抽样点数,默认 `100000`。设为 `0` 表示使用全部点。 - `--no_error_stats`: 跳过误差统计。 ## 输出文件 默认启用 ICP 时: ```text results/aligned_pointcloud.ply results/T_rigid_icp.txt results/alignment_error_stats.txt ``` 使用 `--no_icp` 时: ```text results/aligned_pointcloud_translation_only.ply results/T_translation_only.txt results/alignment_error_stats.txt ``` CAD 采样缓存默认保存在: ```text results/cad_cache/ ``` 默认对齐点云以 compact float32 XYZ PLY 写出,文件体积会接近原始 float32 点云。如果需要 Open3D 默认写出方式: ```powershell python translate_align_pointcloud_to_cad.py --no_visualize --save_aligned_float64 ```