40#include <pcl/filters/model_outlier_removal.h>
41#include <pcl/common/point_tests.h>
42#include <pcl/sample_consensus/sac_model_circle.h>
43#include <pcl/sample_consensus/sac_model_cylinder.h>
44#include <pcl/sample_consensus/sac_model_cone.h>
45#include <pcl/sample_consensus/sac_model_line.h>
46#include <pcl/sample_consensus/sac_model_normal_plane.h>
47#include <pcl/sample_consensus/sac_model_normal_sphere.h>
48#include <pcl/sample_consensus/sac_model_parallel_plane.h>
49#include <pcl/sample_consensus/sac_model_normal_parallel_plane.h>
50#include <pcl/sample_consensus/sac_model_parallel_line.h>
51#include <pcl/sample_consensus/sac_model_perpendicular_plane.h>
52#include <pcl/sample_consensus/sac_model_plane.h>
53#include <pcl/sample_consensus/sac_model_sphere.h>
56template <
typename Po
intT>
bool
57pcl::ModelOutlierRemoval<PointT>::initSACModel (
pcl::SacModel model_type)
64 PCL_DEBUG (
"[pcl::%s::initSACModel] Using a model of type: modelPLANE\n", getClassName ().c_str ());
65 model_.reset (
new SampleConsensusModelPlane<PointT> (input_));
70 PCL_DEBUG (
"[pcl::%s::initSACModel] Using a model of type: modelLINE\n", getClassName ().c_str ());
71 model_.reset (
new SampleConsensusModelLine<PointT> (input_));
76 PCL_DEBUG (
"[pcl::%s::initSACModel] Using a model of type: modelCIRCLE2D\n", getClassName ().c_str ());
77 model_.reset (
new SampleConsensusModelCircle2D<PointT> (input_));
82 PCL_DEBUG (
"[pcl::%s::initSACModel] Using a model of type: modelSPHERE\n", getClassName ().c_str ());
83 model_.reset (
new SampleConsensusModelSphere<PointT> (input_));
88 PCL_DEBUG (
"[pcl::%s::initSACModel] Using a model of type: modelPARALLEL_LINE\n", getClassName ().c_str ());
89 model_.reset (
new SampleConsensusModelParallelLine<PointT> (input_));
94 PCL_DEBUG (
"[pcl::%s::initSACModel] Using a model of type: modelPERPENDICULAR_PLANE\n", getClassName ().c_str ());
95 model_.reset (
new SampleConsensusModelPerpendicularPlane<PointT> (input_));
100 PCL_DEBUG (
"[pcl::%s::segment] Using a model of type: modelCYLINDER\n", getClassName ().c_str ());
101 model_.reset (
new SampleConsensusModelCylinder<PointT, pcl::Normal> (input_));
106 PCL_DEBUG (
"[pcl::%s::segment] Using a model of type: modelNORMAL_PLANE\n", getClassName ().c_str ());
107 model_.reset (
new SampleConsensusModelNormalPlane<PointT, pcl::Normal> (input_));
112 PCL_DEBUG (
"[pcl::%s::segment] Using a model of type: modelCONE\n", getClassName ().c_str ());
113 model_.reset (
new SampleConsensusModelCone<PointT, pcl::Normal> (input_));
118 PCL_DEBUG (
"[pcl::%s::segment] Using a model of type: modelNORMAL_SPHERE\n", getClassName ().c_str ());
119 model_.reset (
new SampleConsensusModelNormalSphere<PointT, pcl::Normal> (input_));
124 PCL_DEBUG (
"[pcl::%s::segment] Using a model of type: modelNORMAL_PARALLEL_PLANE\n", getClassName ().c_str ());
125 model_.reset (
new SampleConsensusModelNormalParallelPlane<PointT, pcl::Normal> (input_));
130 PCL_DEBUG (
"[pcl::%s::segment] Using a model of type: modelPARALLEL_PLANE\n", getClassName ().c_str ());
131 model_.reset (
new SampleConsensusModelParallelPlane<PointT> (input_));
136 PCL_ERROR (
"[pcl::%s::initSACModel] No valid model given!\n", getClassName ().c_str ());
144template <
typename Po
intT>
void
150 int oii = 0, rii = 0;
152 bool valid_setup =
true;
158 auto *model_from_normals =
dynamic_cast<SACModelFromNormals *
> (& (*model_));
160 if (model_from_normals)
165 PCL_ERROR (
"[pcl::ModelOutlierRemoval::applyFilterIndices]: no normals cloud set.\n");
183 (*removed_indices_)[rii++] = iii;
186 indices[oii++] = iii;
199 for (
int iii = 0; iii < static_cast<int> (
indices_->size ()); ++iii)
205 (*removed_indices_)[rii++] = (*indices_)[iii];
216 (*removed_indices_)[rii++] = (*indices_)[iii];
224 (*removed_indices_)[rii++] = (*indices_)[iii];
229 indices[oii++] = (*indices_)[iii];
234 indices.resize (oii);
239#define PCL_INSTANTIATE_ModelOutlierRemoval(T) template class PCL_EXPORTS pcl::ModelOutlierRemoval<T>;
bool extract_removed_indices_
Set to true if we want to return the indices of the removed points.
IndicesPtr removed_indices_
Indices of the points that are removed.
bool negative_
False = normal filter behavior (default), true = inverted behavior.
Eigen::VectorXf model_coefficients_
The model coefficients.
std::function< bool(double)> threshold_function_
void applyFilterIndices(Indices &indices)
Filtered results are indexed by an indices array.
pcl::SacModel model_type_
The type of model to use (user given parameter).
SampleConsensusModelPtr model_
The model used to calculate distances.
double normals_distance_weight_
PointCloudNConstPtr cloud_normals_
PointCloudConstPtr input_
The input point cloud dataset.
IndicesPtr indices_
A pointer to the vector of point indices to use.
SampleConsensusModelFromNormals represents the base model class for models that require the use of su...
bool isFinite(const PointT &pt)
Tests if the 3D components of a point are all finite param[in] pt point to be tested return true if f...
IndicesAllocator<> Indices
Type used for indices in PCL.
@ SACMODEL_PARALLEL_PLANE
@ SACMODEL_NORMAL_PARALLEL_PLANE
@ SACMODEL_PERPENDICULAR_PLANE