41#ifndef PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_NORMAL_SPHERE_H_
42#define PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_NORMAL_SPHERE_H_
44#include <pcl/sample_consensus/sac_model_normal_sphere.h>
48template <
typename Po
intT,
typename Po
intNT>
void
50 const Eigen::VectorXf &model_coefficients,
const double threshold,
Indices &inliers)
54 PCL_ERROR (
"[pcl::SampleConsensusModelNormalSphere::selectWithinDistance] No input dataset containing normals was given! Use setInputNormals\n");
67 Eigen::Vector4f center = model_coefficients;
76 for (std::size_t i = 0; i <
indices_->size (); ++i)
85 Eigen::Vector4f n_dir = p - center;
86 const double weighted_euclid_dist = (1.0 -
normal_distance_weight_) * std::abs (n_dir.norm () - model_coefficients[3]);
87 if (weighted_euclid_dist > threshold)
95 double d_normal = std::abs (
getAngle3D (n, n_dir));
96 d_normal = (std::min) (d_normal,
M_PI - d_normal);
99 if (distance < threshold)
109template <
typename Po
intT,
typename Po
intNT> std::size_t
111 const Eigen::VectorXf &model_coefficients,
const double threshold)
const
115 PCL_ERROR (
"[pcl::SampleConsensusModelNormalSphere::getDistancesToModel] No input dataset containing normals was given! Use setInputNormals\n");
125 Eigen::Vector4f center = model_coefficients;
128 std::size_t nr_p = 0;
131 for (std::size_t i = 0; i <
indices_->size (); ++i)
140 Eigen::Vector4f n_dir = (p-center);
141 const double weighted_euclid_dist = (1.0 -
normal_distance_weight_) * std::abs (n_dir.norm () - model_coefficients[3]);
142 if (weighted_euclid_dist > threshold)
150 double d_normal = std::abs (
getAngle3D (n, n_dir));
151 d_normal = (std::min) (d_normal,
M_PI - d_normal);
160template <
typename Po
intT,
typename Po
intNT>
void
162 const Eigen::VectorXf &model_coefficients, std::vector<double> &
distances)
const
166 PCL_ERROR (
"[pcl::SampleConsensusModelNormalSphere::getDistancesToModel] No input dataset containing normals was given! Use setInputNormals\n");
178 Eigen::Vector4f center = model_coefficients;
184 for (std::size_t i = 0; i <
indices_->size (); ++i)
193 Eigen::Vector4f n_dir = (p-center);
194 const double weighted_euclid_dist = (1.0 -
normal_distance_weight_) * std::abs (n_dir.norm () - model_coefficients[3]);
201 double d_normal = std::abs (
getAngle3D (n, n_dir));
202 d_normal = (std::min) (d_normal,
M_PI - d_normal);
208#define PCL_INSTANTIATE_SampleConsensusModelNormalSphere(PointT, PointNT) template class PCL_EXPORTS pcl::SampleConsensusModelNormalSphere<PointT, PointNT>;
PointCloudNConstPtr normals_
A pointer to the input dataset that contains the point normals of the XYZ dataset.
double normal_distance_weight_
The relative weight (between 0 and 1) to give to the angular distance (0 to pi/2) between point norma...
IndicesPtr indices_
A pointer to the vector of point indices to use.
PointCloudConstPtr input_
A boost shared pointer to the point cloud data array.
std::vector< double > error_sqr_dists_
A vector holding the distances to the computed model.
void selectWithinDistance(const Eigen::VectorXf &model_coefficients, const double threshold, Indices &inliers) override
Select all the points which respect the given model coefficients as inliers.
std::size_t countWithinDistance(const Eigen::VectorXf &model_coefficients, const double threshold) const override
Count all the points which respect the given model coefficients as inliers.
void getDistancesToModel(const Eigen::VectorXf &model_coefficients, std::vector< double > &distances) const override
Compute all distances from the cloud data to a given sphere model.
bool isModelValid(const Eigen::VectorXf &model_coefficients) const override
Check whether a model is valid given the user constraints.
Define standard C methods and C++ classes that are common to all methods.
double getAngle3D(const Eigen::Vector4f &v1, const Eigen::Vector4f &v2, const bool in_degree=false)
Compute the smallest angle between two 3D vectors in radians (default) or degree.
IndicesAllocator<> Indices
Type used for indices in PCL.