I am using the pcl
implementation of iterative closest point
. I would like to be able to play with the inlier points from any registration method that I use.
The registration
class has the ability to output an aligned cloud when the align function is called:
icp_.align(outcloud, guess);
And the PCLBase
class has the following function:
indices = icp_.getIndices();
Unfortunately getIndices
just returns the indices for the entire cloud. I have tested on a cloud and the outliers (or inliers) rejected by distance correspondence don't seem to be retrievable?
I have checked and there are points in the cloud that should have been rejected, see below:
Building off of D.J.Duff's answer, here's one way to get at corresponding points, though it involves violating the class. This one inherits from the IterativeClosestPointNonLinear class and can act as a substitute. For my use case, I just dropped it in wherever I wanted to use IterativeClosestPointNonLinear and be able to access the correspondences_
member. A similar approach could be used for any of the other registration interfaces.
/** \brief This is a mock class with the sole purpose of accessing a protected member of a class it inherits from.
*
* Some of the relevant documentation for correspondences: http://docs.pointclouds.org/trunk/correspondence_8h_source.html#l00092
*/
template <typename PointSource, typename PointTarget, typename Scalar = float>
class IterativeClosestPointNonLinear_Exposed : public pcl::IterativeClosestPointNonLinear<PointSource, PointTarget, Scalar> {
public:
pcl::CorrespondencesPtr getCorrespondencesPtr() {
for (uint32_t i = 0; i < this->correspondences_->size(); i++) {
pcl::Correspondence currentCorrespondence = (*this->correspondences_)[i];
std::cout << "Index of the source point: " << currentCorrespondence.index_query << std::endl;
std::cout << "Index of the matching target point: " << currentCorrespondence.index_match << std::endl;
std::cout << "Distance between the corresponding points: " << currentCorrespondence.distance << std::endl;
std::cout << "Weight of the confidence in the correspondence: " << currentCorrespondence.weight << std::endl;
}
return this->correspondences_;
}
};
Here are some lines drawn between corresponding points between two point clouds obtained in this manner. Notably, the pcl::Correspondence.distance
value between two points doesn't always seem to be strictly less than the value of the registration method's maxCorrespondenceDistance
, so you may have to check the distances to make sure you're getting only the correspondences you want.
I think you may get you want with the protected correspondences_
member:
http://docs.pointclouds.org/1.7.0/classpcl_1_1_registration.html#a98f1c160391fff07f34339b63286e228
As it is protected you probably should subclass ICP and add an accessor method.
For more information about how this member is used, see:
http://docs.pointclouds.org/1.7.0/icp_8hpp_source.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With