51 if (threshold_ == std::numeric_limits<double>::max())
53 PCL_ERROR (
"[pcl::RandomizedMEstimatorSampleConsensus::computeModel] No threshold set!\n");
63 std::vector<double> distances;
69 const unsigned max_skip = max_iterations_ * 10;
72 std::size_t
fraction_nr_points =
pcl_lrint (
static_cast<double>(sac_model_->getIndices ()->size ()) * fraction_nr_pretest_ / 100.0);
78 sac_model_->getSamples (iterations_,
selection);
108 if (distances.empty () && k > 1.0)
111 for (
const double &distance : distances)
125 for (
const double &distance : distances)
126 if (distance <= threshold_)
130 double w =
static_cast<double> (
n_inliers_count) /
static_cast<double>(sac_model_->getIndices ()->size ());
139 PCL_DEBUG (
"[pcl::RandomizedMEstimatorSampleConsensus::computeModel] Trial %d out of %d. Best penalty is %f.\n", iterations_,
static_cast<int> (std::ceil (k)),
d_best_penalty);
140 if (iterations_ > max_iterations_)
143 PCL_DEBUG (
"[pcl::RandomizedMEstimatorSampleConsensus::computeModel] MSAC reached the maximum number of trials.\n");
151 PCL_DEBUG (
"[pcl::RandomizedMEstimatorSampleConsensus::computeModel] Unable to find a solution!\n");
156 sac_model_->getDistancesToModel (model_coefficients_, distances);
157 Indices &indices = *sac_model_->getIndices ();
158 if (distances.size () != indices.
size ())
160 PCL_ERROR (
"[pcl::RandomizedMEstimatorSampleConsensus::computeModel] Estimated distances (%lu) differs than the normal of indices (%lu).\n", distances.size (), indices.
size ());
164 inliers_.resize (distances.size ());
167 for (std::size_t i = 0; i < distances.size (); ++i)
168 if (distances[i] <= threshold_)
175 PCL_DEBUG (
"[pcl::RandomizedMEstimatorSampleConsensus::computeModel] Model: %lu size, %d inliers.\n", model_.size (),
n_inliers_count);