project_inliers.h
/*
* Software License Agreement (BSD License)
*
* Copyright (c) 2010, Willow Garage, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the copyright holder(s) nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id$
*
*/
#pragma once
#include <pcl/point_types.h>
#include <pcl/filters/filter.h>
#include <pcl/ModelCoefficients.h>
// Sample Consensus models
#include <pcl/sample_consensus/model_types.h>
#include <pcl/sample_consensus/sac_model.h>
#include <pcl/sample_consensus/sac_model_circle.h>
#include <pcl/sample_consensus/sac_model_cylinder.h>
#include <pcl/sample_consensus/sac_model_cone.h>
#include <pcl/sample_consensus/sac_model_line.h>
#include <pcl/sample_consensus/sac_model_normal_plane.h>
#include <pcl/sample_consensus/sac_model_normal_sphere.h>
#include <pcl/sample_consensus/sac_model_parallel_plane.h>
#include <pcl/sample_consensus/sac_model_normal_parallel_plane.h>
#include <pcl/sample_consensus/sac_model_parallel_line.h>
#include <pcl/sample_consensus/sac_model_perpendicular_plane.h>
#include <pcl/sample_consensus/sac_model_plane.h>
#include <pcl/sample_consensus/sac_model_sphere.h>
namespace pcl
{
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/** \brief @b ProjectInliers uses a model and a set of inlier indices from a PointCloud to project them into a
* separate PointCloud.
* \author Radu Bogdan Rusu
* \ingroup filters
*/
template<typename PointT>
class ProjectInliers : public Filter<PointT>
{
using Filter<PointT>::input_;
using Filter<PointT>::indices_;
using Filter<PointT>::filter_name_;
using Filter<PointT>::getClassName;
using PointCloud = typename Filter<PointT>::PointCloud;
using PointCloudPtr = typename PointCloud::Ptr;
using PointCloudConstPtr = typename PointCloud::ConstPtr;
using SampleConsensusModelPtr = typename SampleConsensusModel<PointT>::Ptr;
public:
using Ptr = shared_ptr<ProjectInliers<PointT> >;
using ConstPtr = shared_ptr<const ProjectInliers<PointT> >;
/** \brief Empty constructor. */
ProjectInliers () : sacmodel_ (), model_type_ (), copy_all_data_ (false)
{
filter_name_ = "ProjectInliers";
}
/** \brief Empty destructor */
~ProjectInliers () {}
/** \brief The type of model to use (user given parameter).
* \param model the model type (check \a model_types.h)
*/
inline void
setModelType (int model)
{
model_type_ = model;
}
/** \brief Get the type of SAC model used. */
inline int
getModelType ()
{
return (model_type_);
}
/** \brief Provide a pointer to the model coefficients.
* \param model a pointer to the model coefficients
*/
inline void
setModelCoefficients (const ModelCoefficientsConstPtr &model)
{
model_ = model;
}
/** \brief Get a pointer to the model coefficients. */
inline ModelCoefficientsConstPtr
getModelCoefficients ()
{
return (model_);
}
/** \brief Set whether all data will be returned, or only the projected inliers.
* \param val true if all data should be returned, false if only the projected inliers
*/
inline void
setCopyAllData (bool val)
{
copy_all_data_ = val;
}
/** \brief Get whether all data is being copied (true), or only the projected inliers (false). */
inline bool
getCopyAllData ()
{
return (copy_all_data_);
}
protected:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/** \brief Project point indices into a separate PointCloud
* \param output the resultant point cloud message
*/
void
applyFilter (PointCloud &output) override;
private:
/** \brief A pointer to the vector of model coefficients. */
ModelCoefficientsConstPtr model_;
/** \brief The model that needs to be segmented. */
SampleConsensusModelPtr sacmodel_;
/** \brief The type of model to use (user given parameter). */
int model_type_;
/** \brief True if all data will be returned, false if only the projected inliers. Default: false. */
bool copy_all_data_;
/** \brief Initialize the Sample Consensus model and set its parameters.
* \param model_type the type of SAC model that is to be used
*/
virtual bool
initSACModel (int model_type);
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/** \brief @b ProjectInliers uses a model and a set of inlier indices from a PointCloud to project them into a
* separate PointCloud.
* \note setFilterFieldName (), setFilterLimits (), and setFilterLimitNegative () are ignored.
* \author Radu Bogdan Rusu
* \ingroup filters
*/
template<>
class PCL_EXPORTS ProjectInliers<pcl::PCLPointCloud2> : public Filter<pcl::PCLPointCloud2>
{
using Filter<pcl::PCLPointCloud2>::filter_name_;
using Filter<pcl::PCLPointCloud2>::getClassName;
using PCLPointCloud2 = pcl::PCLPointCloud2;
using PCLPointCloud2Ptr = PCLPointCloud2::Ptr;
using PCLPointCloud2ConstPtr = PCLPointCloud2::ConstPtr;
using SampleConsensusModelPtr = SampleConsensusModel<PointXYZ>::Ptr;
public:
/** \brief Empty constructor. */
ProjectInliers () : model_type_ (), copy_all_data_ (false), copy_all_fields_ (true)
{
filter_name_ = "ProjectInliers";
}
/** \brief Empty destructor */
~ProjectInliers () {}
/** \brief The type of model to use (user given parameter).
* \param[in] model the model type (check \a model_types.h)
*/
inline void
setModelType (int model)
{
model_type_ = model;
}
/** \brief Get the type of SAC model used. */
inline int
getModelType () const
{
return (model_type_);
}
/** \brief Provide a pointer to the model coefficients.
* \param[in] model a pointer to the model coefficients
*/
inline void
setModelCoefficients (const ModelCoefficientsConstPtr &model)
{
model_ = model;
}
/** \brief Get a pointer to the model coefficients. */
inline ModelCoefficientsConstPtr
getModelCoefficients () const
{
return (model_);
}
/** \brief Set whether all fields should be copied, or only the XYZ.
* \param[in] val true if all fields will be returned, false if only XYZ
*/
inline void
setCopyAllFields (bool val)
{
copy_all_fields_ = val;
}
/** \brief Get whether all fields are being copied (true), or only XYZ (false). */
inline bool
getCopyAllFields () const
{
return (copy_all_fields_);
}
/** \brief Set whether all data will be returned, or only the projected inliers.
* \param[in] val true if all data should be returned, false if only the projected inliers
*/
inline void
setCopyAllData (bool val)
{
copy_all_data_ = val;
}
/** \brief Get whether all data is being copied (true), or only the projected inliers (false). */
inline bool
getCopyAllData () const
{
return (copy_all_data_);
}
protected:
/** \brief The type of model to use (user given parameter). */
int model_type_;
/** \brief True if all data will be returned, false if only the projected inliers. Default: false. */
bool copy_all_data_;
/** \brief True if all fields will be returned, false if only XYZ. Default: true. */
bool copy_all_fields_;
/** \brief A pointer to the vector of model coefficients. */
ModelCoefficientsConstPtr model_;
void
applyFilter (PCLPointCloud2 &output) override;
private:
/** \brief The model that needs to be segmented. */
SampleConsensusModelPtr sacmodel_;
virtual bool
initSACModel (int model_type);
};
}
#ifdef PCL_NO_PRECOMPILE
#include <pcl/filters/impl/project_inliers.hpp>
#endif
pcl
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
point_types.h
pcl::ProjectInliers::setModelCoefficients
void setModelCoefficients(const ModelCoefficientsConstPtr &model)
Provide a pointer to the model coefficients.
Definition: project_inliers.h:115
pcl::ProjectInliers< pcl::PCLPointCloud2 >::ProjectInliers
ProjectInliers()
Empty constructor.
Definition: project_inliers.h:191
pcl::PCLBase::PointCloudConstPtr
typename PointCloud::ConstPtr PointCloudConstPtr
Definition: pcl_base.h:74
pcl::PCLBase::PointCloudPtr
typename PointCloud::Ptr PointCloudPtr
Definition: pcl_base.h:73
pcl::PCLPointCloud2::Ptr
shared_ptr< ::pcl::PCLPointCloud2 > Ptr
Definition: PCLPointCloud2.h:38
pcl::ProjectInliers< pcl::PCLPointCloud2 >::getModelCoefficients
ModelCoefficientsConstPtr getModelCoefficients() const
Get a pointer to the model coefficients.
Definition: project_inliers.h:226
pcl::ProjectInliers< pcl::PCLPointCloud2 >::copy_all_data_
bool copy_all_data_
True if all data will be returned, false if only the projected inliers.
Definition: project_inliers.h:267
pcl::ProjectInliers::Ptr
shared_ptr< ProjectInliers< PointT > > Ptr
Definition: project_inliers.h:82
pcl::PCLBase< pcl::PCLPointCloud2 >::PCLPointCloud2ConstPtr
PCLPointCloud2::ConstPtr PCLPointCloud2ConstPtr
Definition: pcl_base.h:190
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition: projection_matrix.h:52
pcl::ProjectInliers::getCopyAllData
bool getCopyAllData()
Get whether all data is being copied (true), or only the projected inliers (false).
Definition: project_inliers.h:138
pcl::ProjectInliers< pcl::PCLPointCloud2 >::getCopyAllFields
bool getCopyAllFields() const
Get whether all fields are being copied (true), or only XYZ (false).
Definition: project_inliers.h:242
pcl::ProjectInliers::ProjectInliers
ProjectInliers()
Empty constructor.
Definition: project_inliers.h:87
pcl::ProjectInliers< pcl::PCLPointCloud2 >::getCopyAllData
bool getCopyAllData() const
Get whether all data is being copied (true), or only the projected inliers (false).
Definition: project_inliers.h:258
pcl::PCLBase< pcl::PCLPointCloud2 >::PCLPointCloud2Ptr
PCLPointCloud2::Ptr PCLPointCloud2Ptr
Definition: pcl_base.h:189
pcl::PCLPointCloud2::ConstPtr
shared_ptr< const ::pcl::PCLPointCloud2 > ConstPtr
Definition: PCLPointCloud2.h:39
pcl::ProjectInliers< pcl::PCLPointCloud2 >::setModelType
void setModelType(int model)
The type of model to use (user given parameter).
Definition: project_inliers.h:203
pcl::Filter::ConstPtr
shared_ptr< const Filter< PointT > > ConstPtr
Definition: filter.h:90
pcl::ProjectInliers::getModelType
int getModelType()
Get the type of SAC model used.
Definition: project_inliers.h:106
pcl::ProjectInliers< pcl::PCLPointCloud2 >::setModelCoefficients
void setModelCoefficients(const ModelCoefficientsConstPtr &model)
Provide a pointer to the model coefficients.
Definition: project_inliers.h:219
pcl::SampleConsensusModel::Ptr
shared_ptr< SampleConsensusModel< PointT > > Ptr
Definition: sac_model.h:76
pcl::ProjectInliers::~ProjectInliers
~ProjectInliers()
Empty destructor.
Definition: project_inliers.h:93
pcl::ProjectInliers< pcl::PCLPointCloud2 >::getModelType
int getModelType() const
Get the type of SAC model used.
Definition: project_inliers.h:210
pcl::Filter
Filter represents the base filter class.
Definition: filter.h:83
pcl::ProjectInliers< pcl::PCLPointCloud2 >::setCopyAllData
void setCopyAllData(bool val)
Set whether all data will be returned, or only the projected inliers.
Definition: project_inliers.h:251
pcl::ProjectInliers::applyFilter
void applyFilter(PointCloud &output) override
Project point indices into a separate PointCloud.
Definition: project_inliers.hpp:45
pcl::PCLPointCloud2
Definition: PCLPointCloud2.h:19
pcl::Filter::filter_name_
std::string filter_name_
The filter name.
Definition: filter.h:164
pcl::PointCloud::Ptr
shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:415
pcl::ModelCoefficientsConstPtr
ModelCoefficients::ConstPtr ModelCoefficientsConstPtr
Definition: ModelCoefficients.h:28
pcl::ProjectInliers< pcl::PCLPointCloud2 >::model_
ModelCoefficientsConstPtr model_
A pointer to the vector of model coefficients.
Definition: project_inliers.h:273
pcl::ProjectInliers
ProjectInliers uses a model and a set of inlier indices from a PointCloud to project them into a sepa...
Definition: project_inliers.h:68
pcl::ProjectInliers::setCopyAllData
void setCopyAllData(bool val)
Set whether all data will be returned, or only the projected inliers.
Definition: project_inliers.h:131
pcl::PointCloud::ConstPtr
shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:416
pcl::ProjectInliers::setModelType
void setModelType(int model)
The type of model to use (user given parameter).
Definition: project_inliers.h:99
pcl::ProjectInliers< pcl::PCLPointCloud2 >::~ProjectInliers
~ProjectInliers()
Empty destructor.
Definition: project_inliers.h:197
pcl::ProjectInliers< pcl::PCLPointCloud2 >::model_type_
int model_type_
The type of model to use (user given parameter).
Definition: project_inliers.h:264
pcl::ProjectInliers::getModelCoefficients
ModelCoefficientsConstPtr getModelCoefficients()
Get a pointer to the model coefficients.
Definition: project_inliers.h:122
pcl::SampleConsensusModel
SampleConsensusModel represents the base model class.
Definition: sac_model.h:68
PCL_EXPORTS
#define PCL_EXPORTS
Definition: pcl_macros.h:253
pcl::ProjectInliers< pcl::PCLPointCloud2 >::setCopyAllFields
void setCopyAllFields(bool val)
Set whether all fields should be copied, or only the XYZ.
Definition: project_inliers.h:235
pcl::shared_ptr
boost::shared_ptr< T > shared_ptr
Alias for boost::shared_ptr.
Definition: pcl_macros.h:90
pcl::ProjectInliers< pcl::PCLPointCloud2 >::copy_all_fields_
bool copy_all_fields_
True if all fields will be returned, false if only XYZ.
Definition: project_inliers.h:270