VTK Registration
点云配准分为两步,先做粗配准,再做精配准:
粗配准(Coarse Global Registeration):基于局部几何特征
精配准(Fine Local Registeration):需要初始位姿(initial alignment)
这里讲一下 VTK 的 vtkLandmarkTransform 可用于精配准;
精配准 见 vtkIterativeClosestPointTransform
vtkLandmarkTransform
vtkLandmarkTransform是一种比较经典的匹配算法,基于标记点,两个点集在配准后的平均距离最小,要求输入两个点数必须相等,序号一致的点集,做线性变换。它常用于粗略匹配,效率高。
源点
vtkNew<vtkPoints> sourcePoints;
double sourcePoint1[3] = {1.0, 0.0, 0.0};
sourcePoints->InsertNextPoint(sourcePoint1);
double sourcePoint2[3] = {0.0, 1.0, 0.0};
sourcePoints->InsertNextPoint(sourcePoint2);
double sourcePoint3[3] = {0.0, 0.0, 1.0};
sourcePoints->InsertNextPoint(sourcePoint3);
目标点
vtkNew<vtkPoints> targetPoints;
double targetPoint1[3] = {0.0, 0.0, 1.1};
targetPoints->InsertNextPoint(targetPoint1);
double targetPoint2[3] = {0.0, 1.02, 0.0};
targetPoints->InsertNextPoint(targetPoint2);
double targetPoint3[3] = {-1.11, 0.0, 0.0};
targetPoints->InsertNextPoint(targetPoint3);
获取转换矩阵--变换矩阵
// Setup the transform
vtkNew<vtkLandmarkTransform> landmarkTransform;
landmarkTransform->SetSourceLandmarks(sourcePoints);
landmarkTransform->SetTargetLandmarks(targetPoints);
landmarkTransform->SetModeToRigidBody();
landmarkTransform->Update(); // should this be here?
// Display the transformation matrix that was computed
vtkMatrix4x4* mat = landmarkTransform->GetMatrix();
std::cout << "Matrix: " << *mat << std::endl;