40 #ifndef PCL_SAMPLE_CONSENSUS_MODEL_REGISTRATION_H_
41 #define PCL_SAMPLE_CONSENSUS_MODEL_REGISTRATION_H_
43 #include <boost/unordered_map.hpp>
56 template <
typename Po
intT>
67 typedef boost::shared_ptr<SampleConsensusModelRegistration>
Ptr;
77 sample_dist_thresh_ (0)
88 const std::vector<int> &indices) :
93 sample_dist_thresh_ (0)
95 computeOriginalIndexMapping ();
96 computeSampleDistanceThreshold (cloud, indices);
106 computeOriginalIndexMapping ();
107 computeSampleDistanceThreshold (cloud);
117 indices_tgt_.reset (
new std::vector<int>);
119 int target_size =
static_cast<int> (target->size ());
120 indices_tgt_->resize (target_size);
122 for (
int i = 0; i < target_size; ++i)
123 (*indices_tgt_)[i] = i;
124 computeOriginalIndexMapping ();
135 indices_tgt_.reset (
new std::vector<int> (indices_tgt));
136 computeOriginalIndexMapping ();
145 Eigen::VectorXf &model_coefficients);
153 std::vector<double> &distances);
162 const double threshold,
163 std::vector<int> &inliers);
173 const double threshold);
182 const Eigen::VectorXf &model_coefficients,
183 Eigen::VectorXf &optimized_coefficients);
187 const Eigen::VectorXf &,
194 const Eigen::VectorXf &,
209 isModelValid (
const Eigen::VectorXf &model_coefficients)
212 if (model_coefficients.size () != 16)
223 isSampleGood (
const std::vector<int> &samples)
const;
233 Eigen::Vector4f xyz_centroid;
234 Eigen::Matrix3f covariance_matrix = Eigen::Matrix3f::Zero ();
239 for (
int i = 0; i < 3; ++i)
240 for (
int j = 0; j < 3; ++j)
242 PCL_ERROR (
"[pcl::SampleConsensusModelRegistration::computeSampleDistanceThreshold] Covariance matrix has NaN values! Is the input cloud finite?\n");
244 Eigen::Vector3f eigen_values;
248 sample_dist_thresh_ = eigen_values.array ().sqrt ().sum () / 3.0;
249 sample_dist_thresh_ *= sample_dist_thresh_;
250 PCL_DEBUG (
"[pcl::SampleConsensusModelRegistration::setInputCloud] Estimated a sample selection distance threshold of: %f\n", sample_dist_thresh_);
259 const std::vector<int> &indices)
262 Eigen::Vector4f xyz_centroid;
263 Eigen::Matrix3f covariance_matrix;
267 for (
int i = 0; i < 3; ++i)
268 for (
int j = 0; j < 3; ++j)
270 PCL_ERROR (
"[pcl::SampleConsensusModelRegistration::computeSampleDistanceThreshold] Covariance matrix has NaN values! Is the input cloud finite?\n");
272 Eigen::Vector3f eigen_values;
276 sample_dist_thresh_ = eigen_values.array ().sqrt ().sum () / 3.0;
277 sample_dist_thresh_ *= sample_dist_thresh_;
278 PCL_DEBUG (
"[pcl::SampleConsensusModelRegistration::setInputCloud] Estimated a sample selection distance threshold of: %f\n", sample_dist_thresh_);
296 const std::vector<int> &indices_src,
298 const std::vector<int> &indices_tgt,
299 Eigen::VectorXf &transform);
303 computeOriginalIndexMapping ()
305 if (!indices_tgt_ || !indices_ || indices_->empty () || indices_->size () != indices_tgt_->size ())
307 for (
size_t i = 0; i < indices_->size (); ++i)
308 correspondences_[(*indices_)[i]] = (*indices_tgt_)[i];
315 boost::shared_ptr <std::vector<int> > indices_tgt_;
318 boost::unordered_map<int, int> correspondences_;
321 double sample_dist_thresh_;
323 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
329 #endif //#ifndef PCL_SAMPLE_CONSENSUS_MODEL_REGISTRATION_H_