51 if (threshold_ == std::numeric_limits<double>::max())
53 PCL_ERROR (
"[pcl::MEstimatorSampleConsensus::computeModel] No threshold set!\n");
63 std::vector<double> distances;
68 const unsigned max_skip = max_iterations_ * 10;
74 sac_model_->getSamples (iterations_,
selection);
90 if (distances.empty () && k > 1.0)
93 for (
const double &distance : distances)
107 for (
const double &distance : distances)
108 if (distance <= threshold_)
112 double w =
static_cast<double> (
n_inliers_count) /
static_cast<double> (sac_model_->getIndices ()->size ());
116 k = std::log (1.0 - probability_) / std::log (
p_no_outliers);
121 PCL_DEBUG (
"[pcl::MEstimatorSampleConsensus::computeModel] Trial %d out of %d. Best penalty is %f.\n", iterations_,
static_cast<int> (std::ceil (k)),
d_best_penalty);
122 if (iterations_ > max_iterations_)
125 PCL_DEBUG (
"[pcl::MEstimatorSampleConsensus::computeModel] MSAC reached the maximum number of trials.\n");
133 PCL_DEBUG (
"[pcl::MEstimatorSampleConsensus::computeModel] Unable to find a solution!\n");
138 sac_model_->getDistancesToModel (model_coefficients_, distances);
139 Indices &indices = *sac_model_->getIndices ();
141 if (distances.size () != indices.
size ())
143 PCL_ERROR (
"[pcl::MEstimatorSampleConsensus::computeModel] Estimated distances (%lu) differs than the normal of indices (%lu).\n", distances.size (), indices.
size ());
147 inliers_.resize (distances.size ());
150 for (std::size_t i = 0; i < distances.size (); ++i)
151 if (distances[i] <= threshold_)
158 PCL_DEBUG (
"[pcl::MEstimatorSampleConsensus::computeModel] Model: %lu size, %d inliers.\n", model_.size (),
n_inliers_count);