Skip to content

Commit 034cbfd

Browse files
WIP: improvements on documentation and removal of hard-coded parameters
1 parent 0534d67 commit 034cbfd

File tree

2 files changed

+75
-72
lines changed

2 files changed

+75
-72
lines changed

src/diffCheck/registration/globalregistration.cc

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "globalRegistration.hh"
22

33
namespace diffCheck::registration
4-
{
4+
{
55
std::vector<double> GlobalRegistration::ComputeP2PDistance(std::shared_ptr<geometry::DFPointCloud> source, std::shared_ptr<geometry::DFPointCloud> target)
66
{
77
std::vector<double> errors;
@@ -13,6 +13,7 @@ namespace diffCheck::registration
1313
distances = O3DSourcePointCloud->ComputePointCloudDistance(*O3DTargetPointCloud);
1414
return distances;
1515
}
16+
1617
open3d::pipelines::registration::RegistrationResult GlobalRegistration::O3DFastGlobalRegistrationFeatureMatching(std::shared_ptr<geometry::DFPointCloud> source,
1718
std::shared_ptr<geometry::DFPointCloud> target,
1819
double voxelSize,
@@ -21,23 +22,21 @@ namespace diffCheck::registration
2122
double maxCorrespondenceDistance,
2223
int iterationNumber,
2324
int maxTupleCount)
24-
25-
26-
{
25+
{
2726
std::shared_ptr<open3d::geometry::PointCloud> sourceO3D = source->Cvt2O3DPointCloud();
2827
std::shared_ptr<open3d::geometry::PointCloud> targetO3D = target->Cvt2O3DPointCloud();
2928

30-
sourceO3D->VoxelDownSample(0.01);
31-
targetO3D->VoxelDownSample(0.01);
29+
sourceO3D->VoxelDownSample(voxelSize);
30+
targetO3D->VoxelDownSample(voxelSize);
3231

3332
std::shared_ptr<open3d::pipelines::registration::Feature> sourceFPFHFeatures = open3d::pipelines::registration::ComputeFPFHFeature(*sourceO3D,
3433
open3d::geometry::KDTreeSearchParamHybrid(radiusKDTreeSearch, maxNeighborKDTreeSearch));
3534
std::shared_ptr<open3d::pipelines::registration::Feature> targetFPFHFeatures = open3d::pipelines::registration::ComputeFPFHFeature(*targetO3D,
3635
open3d::geometry::KDTreeSearchParamHybrid(radiusKDTreeSearch, maxNeighborKDTreeSearch));
3736
std::shared_ptr<open3d::pipelines::registration::FastGlobalRegistrationOption> option = std::make_shared<open3d::pipelines::registration::FastGlobalRegistrationOption>();
38-
option->maximum_correspondence_distance_ = 0.05;
39-
option->iteration_number_ = 100;
40-
option->maximum_tuple_count_ = 500;
37+
option->maximum_correspondence_distance_ = maxCorrespondenceDistance;
38+
option->iteration_number_ = iterationNumber;
39+
option->maximum_tuple_count_ = maxTupleCount;
4140

4241
auto result = open3d::pipelines::registration::FastGlobalRegistrationBasedOnFeatureMatching(*sourceO3D,
4342
*targetO3D,
@@ -60,13 +59,13 @@ namespace diffCheck::registration
6059
std::shared_ptr<open3d::geometry::PointCloud> sourceO3D = source->Cvt2O3DPointCloud();
6160
std::shared_ptr<open3d::geometry::PointCloud> targetO3D = target->Cvt2O3DPointCloud();
6261

63-
sourceO3D->VoxelDownSample(0.01);
64-
targetO3D->VoxelDownSample(0.01);
62+
sourceO3D->VoxelDownSample(voxelSize);
63+
targetO3D->VoxelDownSample(voxelSize);
6564

6665
std::shared_ptr<open3d::pipelines::registration::FastGlobalRegistrationOption> option = std::make_shared<open3d::pipelines::registration::FastGlobalRegistrationOption>();
67-
option->maximum_correspondence_distance_ = 0.05;
68-
option->iteration_number_ = 100;
69-
option->maximum_tuple_count_ = 500;
66+
option->maximum_correspondence_distance_ = maxCorrespondenceDistance;
67+
option->iteration_number_ = iterationNumber;
68+
option->maximum_tuple_count_ = maxTupleCount;
7069

7170
std::shared_ptr<open3d::pipelines::registration::Feature> sourceFPFHFeatures = open3d::pipelines::registration::ComputeFPFHFeature(*sourceO3D,
7271
open3d::geometry::KDTreeSearchParamHybrid(radiusKDTreeSearch, maxNeighborKDTreeSearch));
@@ -95,8 +94,8 @@ namespace diffCheck::registration
9594
std::shared_ptr<open3d::geometry::PointCloud> sourceO3D = source->Cvt2O3DPointCloud();
9695
std::shared_ptr<open3d::geometry::PointCloud> targetO3D = target->Cvt2O3DPointCloud();
9796

98-
sourceO3D->VoxelDownSample(0.01);
99-
targetO3D->VoxelDownSample(0.01);
97+
sourceO3D->VoxelDownSample(voxelSize);
98+
targetO3D->VoxelDownSample(voxelSize);
10099

101100
std::shared_ptr<open3d::pipelines::registration::Feature> sourceFPFHFeatures = open3d::pipelines::registration::ComputeFPFHFeature(*sourceO3D,
102101
open3d::geometry::KDTreeSearchParamHybrid(radiusKDTreeSearch, maxNeighborKDTreeSearch));
@@ -126,8 +125,8 @@ namespace diffCheck::registration
126125
std::shared_ptr<open3d::geometry::PointCloud> sourceO3D = source->Cvt2O3DPointCloud();
127126
std::shared_ptr<open3d::geometry::PointCloud> targetO3D = target->Cvt2O3DPointCloud();
128127

129-
sourceO3D->VoxelDownSample(0.01);
130-
targetO3D->VoxelDownSample(0.01);
128+
sourceO3D->VoxelDownSample(voxelSize);
129+
targetO3D->VoxelDownSample(voxelSize);
131130

132131
std::shared_ptr<open3d::pipelines::registration::Feature> sourceFPFHFeatures = open3d::pipelines::registration::ComputeFPFHFeature(*sourceO3D,
133132
open3d::geometry::KDTreeSearchParamHybrid(radiusKDTreeSearch, maxNeighborKDTreeSearch));

src/diffCheck/registration/globalregistration.hh

Lines changed: 58 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,38 @@ namespace diffCheck::registration
99
class GlobalRegistration
1010
{
1111
public:
12-
12+
13+
/**
14+
* @brief Compute the "point to point" distance between two point clouds.
15+
* For every point in the source point cloud it looks in the KDTree of the target point cloud and finds the closest point.
16+
* It returns a vector of distances, one for each point in the source point cloud.
17+
* @param source The source diffCheck point cloud
18+
* @param target The target diffCheck point cloud
19+
*
20+
* @see https://github.com/isl-org/Open3D/blob/main/cpp/open3d/geometry/PointCloud.cpp
21+
*/
1322
static std::vector<double> ComputeP2PDistance(std::shared_ptr<geometry::DFPointCloud> source,
1423
std::shared_ptr<geometry::DFPointCloud> target);
1524

1625
/**
17-
Documentation on Fast Point Feature Historigrams: https://pcl.readthedocs.io/projects/tutorials/en/latest/fpfh_estimation.html
1826
19-
Very simply, point features are values computed on a point cloud (for example the normal of a point, the curvature, etc.).
20-
point features historigrams generalize this concept by computing point features in a local neighborhood of a point, stored as higher-dimentional historigrams.
21-
22-
For example, for a given point, you take all the neighboring points within a given radius, and create a complete graph on those vertices.
23-
then for each edge of the graph you compute features that are then stored in a historigram of the original center point from which the sphere and the graph where built.
24-
https://pcl.readthedocs.io/projects/tutorials/en/latest/pfh_estimation.html#pfh-estimation proposes a simple example of such a historigram.
25-
26-
PCL's documentation refers to this 2009 TUM PhD thesis (but largely outside the scope of our work): https://mediatum.ub.tum.de/doc/800632/941254.pdf
27-
28-
Quite important for us: the resultant hyperspace is dependent on the quality of the surface normal estimations at each point (if pc noisy, historigram different).
29-
30-
@param source the source point cloud
31-
@param target the target point cloud
32-
@param voxelSize the size of the voxels used to downsample the point clouds
33-
@param radiusKDTreeSearch the radius used to search for neighbors in the KDTree. It is used for the calculation of FPFHFeatures
34-
@param maxNeighborKDTreeSearch the maximum number of neighbors to search for in the KDTree. It is used for the calculation of FPFHFeatures
35-
@param maxCorrespondenceDistance the maximum distance between correspondences.
36-
@param iterationNumber the number of iterations to run the RanSaC registration algorithm
37-
@param maxTupleCount the maximum number of tuples to consider in the FPFH hyperspace
27+
* @brief Fast Global Registration based on Feature Matching using (Fast) Point Feature Histograms (FPFH) on the source and target point clouds
28+
*
29+
* Very simply, point features are values computed on a point cloud (for example the normal of a point, the curvature, etc.).
30+
* point features historigrams generalize this concept by computing point features in a local neighborhood of a point, stored as higher-dimentional historigrams.
31+
*
32+
* Quite important for us: the resultant hyperspace is dependent on the quality of the surface normal estimations at each point (if pc noisy, historigram different).
33+
* @param source the source diffCheck point cloud
34+
* @param target the target diffCheck point cloud
35+
* @param voxelSize the size of the voxels used to downsample the point clouds. A higher value will result in a more coarse point cloud (less resulting points).
36+
* @param radiusKDTreeSearch the radius used to search for neighbors in the KDTree. It is used for the calculation of FPFHFeatures. A higher value will result in heavier computation but potentially more precise.
37+
* @param maxNeighborKDTreeSearch the maximum number of neighbors to search for in the KDTree. It is used for the calculation of FPFHFeatures. A higher value will result in heavier computation but potentially more precise.
38+
* @param maxCorrespondenceDistance the maximum distance between correspondences. As parameter of the FastGlobalRegistrationOption options
39+
* @param iterationNumber the number of iterations to run the RanSaC registration algorithm. A higher value will take more time to compute but increases the chances of finding a good transformation. As parameter of the FastGlobalRegistrationOption options
40+
* @param maxTupleCount the maximum number of tuples to consider in the FPFH hyperspace. A higher value will result in heavier computation but potentially more precise. As parameter of the FastGlobalRegistrationOption options
41+
*
42+
* @see https://pcl.readthedocs.io/projects/tutorials/en/latest/pfh_estimation.html#pfh-estimation for more information on PFH (from PCL, not Open3D)
43+
* @see https://mediatum.ub.tum.de/doc/800632/941254.pdf for in-depth documentation on the theory
3844
*/
3945
static open3d::pipelines::registration::RegistrationResult O3DFastGlobalRegistrationFeatureMatching(std::shared_ptr<geometry::DFPointCloud> source,
4046
std::shared_ptr<geometry::DFPointCloud> target,
@@ -46,17 +52,17 @@ class GlobalRegistration
4652
int maxTupleCount = 500);
4753

4854
/**
49-
Little information on this registration method compared to the previous one.
50-
If I understand correctly, this method finds keypoints in the FPFH hyperspaces of the source and target point clouds and then tries to match them.
51-
https://pcl.readthedocs.io/projects/tutorials/en/latest/correspondence_grouping.html
52-
53-
@param source the source point cloud
54-
@param target the target point cloud
55-
@param voxelSize the size of the voxels used to downsample the point clouds
56-
@param radiusKDTreeSearch the radius used to search for neighbors in the KDTree. It is used for the calculation of FPFHFeatures
57-
@param maxNeighborKDTreeSearch the maximum number of neighbors to search for in the KDTree. It is used for the calculation of FPFHFeatures
58-
@param iterationNumber the number of iterations to run the RanSaC registration algorithm
59-
@param maxTupleCount the maximum number of tuples to consider in the FPFH hyperspace
55+
* @brief Fast Global Registration based on Correspondence using (Fast) Point Feature Histograms (FPFH) on the source and target point clouds
56+
* Little information on this registration method compared to the previous one.
57+
* If understood correctly, this method finds keypoints in the FPFH hyperspaces of the source and target point clouds and then tries to match them, instead of using all the features.
58+
* https://pcl.readthedocs.io/projects/tutorials/en/latest/correspondence_grouping.html
59+
* @param source the source diffCheck point cloud
60+
* @param target the target diffCheck point cloud
61+
* @param voxelSize the size of the voxels used to downsample the point clouds. A higher value will result in a more coarse point cloud (less resulting points).
62+
* @param radiusKDTreeSearch the radius used to search for neighbors in the KDTree. It is used for the calculation of FPFHFeatures
63+
* @param maxNeighborKDTreeSearch the maximum number of neighbors to search for in the KDTree. It is used for the calculation of FPFHFeatures
64+
* @param iterationNumber the number of iterations to run the RanSaC registration algorithm
65+
* @param maxTupleCount the maximum number of tuples to consider in the FPFH hyperspace
6066
*/
6167
static open3d::pipelines::registration::RegistrationResult O3DFastGlobalRegistrationBasedOnCorrespondence(std::shared_ptr<geometry::DFPointCloud> source,
6268
std::shared_ptr<geometry::DFPointCloud> target,
@@ -67,21 +73,20 @@ class GlobalRegistration
6773
int iterationNumber = 100,
6874
int maxTupleCount = 500);
6975
/**
70-
Ransac registration based on correspondence:
71-
Correspondances are computed between the source and target point clouds.
72-
Then, a transformation is computed that minimizes the error between the correspondances.
73-
If the error is above a certain threshold, the transformation is discarded and a new one is computed.
76+
* @brief Ransac registration based on Feature Matching using (Fast) Point Feature Histograms (FPFH) on the source and target point clouds
77+
* Correspondances are computed between the source and target point clouds.
78+
* Then, a transformation is computed that minimizes the error between the correspondances.
79+
* If the error is above a certain threshold, the transformation is discarded and a new one is computed.
7480
75-
In practice, Open3D gives little information about the feature correspondence, compared to the FGR methods
76-
77-
@param source the source point cloud
78-
@param target the target point cloud
79-
@param voxelSize the size of the voxels used to downsample the point clouds
80-
@param radiusKDTreeSearch the radius used to search for neighbors in the KDTree. It is used for the calculation of FPFHFeatures
81-
@param maxNeighborKDTreeSearch the maximum number of neighbors to search for in the KDTree. It is used for the calculation of FPFHFeatures
82-
@param maxCorrespondenceDistance the maximum distance between correspondences.
83-
@param correspondenceSetSize the number of correspondences to consider in the Ransac algorithm
81+
* In practice, Open3D gives little information about the feature correspondence, compared to the FGR methods
8482
83+
* @param source the source diffCheck point cloud
84+
* @param target the target diffCheck point cloud
85+
* @param voxelSize the size of the voxels used to downsample the point clouds. A higher value will result in a more coarse point cloud (less resulting points).
86+
* @param radiusKDTreeSearch the radius used to search for neighbors in the KDTree. It is used for the calculation of FPFHFeatures
87+
* @param maxNeighborKDTreeSearch the maximum number of neighbors to search for in the KDTree. It is used for the calculation of FPFHFeatures
88+
* @param maxCorrespondenceDistance the maximum distance between correspondences.
89+
* @param correspondenceSetSize the number of correspondences to consider in the Ransac algorithm
8590
*/
8691
static open3d::pipelines::registration::RegistrationResult O3DRansacOnCorrespondence(std::shared_ptr<geometry::DFPointCloud> source,
8792
std::shared_ptr<geometry::DFPointCloud> target,
@@ -91,15 +96,14 @@ class GlobalRegistration
9196
double maxCorrespondenceDistance = 0.05,
9297
int correspondenceSetSize = 200);
9398
/**
94-
Ransac registration based on Feature Matching
95-
https://www.open3d.org/docs/release/tutorial/pipelines/global_registration.html#RANSAC
96-
97-
@param source the source point cloud
98-
@param target the target point cloud
99-
@param voxelSize the size of the voxels used to downsample the point clouds
100-
@param radiusKDTreeSearch the radius used to search for neighbors in the KDTree. It is used for the calculation of FPFHFeatures
101-
@param maxNeighborKDTreeSearch the maximum number of neighbors to search for in the KDTree. It is used for the calculation of FPFHFeatures
102-
@param maxCorrespondenceDistance the maximum distance between correspondences.
99+
* @brief Ransac registration based on Feature Matching using (Fast) Point Feature Histograms (FPFH) on the source and target point clouds
100+
* https://www.open3d.org/docs/release/tutorial/pipelines/global_registration.html#RANSAC
101+
* @param source the source diffCheck point cloud
102+
* @param target the target diffCheck point cloud
103+
* @param voxelSize the size of the voxels used to downsample the point clouds. A higher value will result in a more coarse point cloud (less resulting points).
104+
* @param radiusKDTreeSearch the radius used to search for neighbors in the KDTree. It is used for the calculation of FPFHFeatures
105+
* @param maxNeighborKDTreeSearch the maximum number of neighbors to search for in the KDTree. It is used for the calculation of FPFHFeatures
106+
* @param maxCorrespondenceDistance the maximum distance between correspondences.
103107
*/
104108
static open3d::pipelines::registration::RegistrationResult O3DRansacOnFeatureMatching(std::shared_ptr<geometry::DFPointCloud> source,
105109
std::shared_ptr<geometry::DFPointCloud> target,

0 commit comments

Comments
 (0)