@@ -117,45 +117,34 @@ RegistrationResult RegistrationICP(
117
117
if (max_correspondence_distance <= 0.0 ) {
118
118
utility::LogError (" Invalid max_correspondence_distance." );
119
119
}
120
- if ((estimation.GetTransformationEstimationType () ==
121
- TransformationEstimationType::PointToPlane ||
122
- estimation.GetTransformationEstimationType () ==
123
- TransformationEstimationType::ColoredICP) &&
124
- (!target.HasNormals ())) {
125
- utility::LogError (
126
- " TransformationEstimationPointToPlane and "
127
- " TransformationEstimationColoredICP "
128
- " require pre-computed normal vectors for target PointCloud." );
129
- }
130
- if ((estimation.GetTransformationEstimationType () ==
131
- TransformationEstimationType::GeneralizedICP) &&
132
- (!target.HasCovariances () || !source.HasCovariances ())) {
133
- utility::LogError (
134
- " TransformationEstimationForGeneralizedICP require "
135
- " pre-computed per point covariances matrices for source and "
136
- " target PointCloud." );
137
- }
120
+
121
+ auto [source_initialized_c, target_initialized_c] =
122
+ estimation.InitializePointCloudsForTransformation (
123
+ source, target, max_correspondence_distance);
138
124
139
125
Eigen::Matrix4d transformation = init;
140
126
geometry::KDTreeFlann kdtree;
141
- kdtree.SetGeometry (target);
142
- geometry::PointCloud pcd = source;
127
+ const geometry::PointCloud &target_initialized = *target_initialized_c;
128
+ kdtree.SetGeometry (target_initialized);
129
+ geometry::PointCloud pcd (*source_initialized_c);
130
+
143
131
if (!init.isIdentity ()) {
144
132
pcd.Transform (init);
145
133
}
146
134
RegistrationResult result;
147
135
result = GetRegistrationResultAndCorrespondences (
148
- pcd, target, kdtree, max_correspondence_distance, transformation);
136
+ pcd, target_initialized, kdtree, max_correspondence_distance,
137
+ transformation);
149
138
for (int i = 0 ; i < criteria.max_iteration_ ; i++) {
150
139
utility::LogDebug (" ICP Iteration #{:d}: Fitness {:.4f}, RMSE {:.4f}" , i,
151
140
result.fitness_ , result.inlier_rmse_ );
152
141
Eigen::Matrix4d update = estimation.ComputeTransformation (
153
- pcd, target , result.correspondence_set_ );
142
+ pcd, target_initialized , result.correspondence_set_ );
154
143
transformation = update * transformation;
155
144
pcd.Transform (update);
156
145
RegistrationResult backup = result;
157
146
result = GetRegistrationResultAndCorrespondences (
158
- pcd, target , kdtree, max_correspondence_distance,
147
+ pcd, target_initialized , kdtree, max_correspondence_distance,
159
148
transformation);
160
149
if (std::abs (backup.fitness_ - result.fitness_ ) <
161
150
criteria.relative_fitness_ &&
0 commit comments