Loading...
Searching...
No Matches
sac_model_normal_sphere.h
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2009-2012, Willow Garage, Inc.
* Copyright (c) 2012-, Open Perception, 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: sac_model_normal_sphere.h schrandt $
*
*/
#pragma once
#include <pcl/sample_consensus/sac_model.h>
#include <pcl/sample_consensus/sac_model_sphere.h>
#include <pcl/sample_consensus/model_types.h>
#include <pcl/memory.h>
#include <pcl/pcl_macros.h>
namespace pcl
{
/** \brief @b SampleConsensusModelNormalSphere defines a model for 3D sphere
* segmentation using additional surface normal constraints. Basically this
* means that checking for inliers will not only involve a "distance to
* model" criterion, but also an additional "maximum angular deviation"
* between the sphere's normal and the inlier points normals.
*
* The model coefficients are defined as:
* <ul>
* <li><b>center.x</b> : the X coordinate of the sphere's center
* <li><b>center.y</b> : the Y coordinate of the sphere's center
* <li><b>center.z</b> : the Z coordinate of the sphere's center
* <li><b>radius</b> : radius of the sphere
* </ul>
*
* \author Stefan Schrandt
* \ingroup sample_consensus
*/
template <typename PointT, typename PointNT>
class SampleConsensusModelNormalSphere : public SampleConsensusModelSphere<PointT>, public SampleConsensusModelFromNormals<PointT, PointNT>
{
public:
using SampleConsensusModel<PointT>::model_name_;
using SampleConsensusModel<PointT>::input_;
using SampleConsensusModel<PointT>::indices_;
using SampleConsensusModel<PointT>::radius_min_;
using SampleConsensusModel<PointT>::radius_max_;
using SampleConsensusModelFromNormals<PointT, PointNT>::normals_;
using SampleConsensusModelFromNormals<PointT, PointNT>::normal_distance_weight_;
using SampleConsensusModel<PointT>::error_sqr_dists_;
using PointCloud = typename SampleConsensusModel<PointT>::PointCloud;
using PointCloudPtr = typename SampleConsensusModel<PointT>::PointCloudPtr;
using PointCloudConstPtr = typename SampleConsensusModel<PointT>::PointCloudConstPtr;
using PointCloudNPtr = typename SampleConsensusModelFromNormals<PointT, PointNT>::PointCloudNPtr;
using PointCloudNConstPtr = typename SampleConsensusModelFromNormals<PointT, PointNT>::PointCloudNConstPtr;
using Ptr = shared_ptr<SampleConsensusModelNormalSphere<PointT, PointNT> >;
using ConstPtr = shared_ptr<const SampleConsensusModelNormalSphere<PointT, PointNT>>;
/** \brief Constructor for base SampleConsensusModelNormalSphere.
* \param[in] cloud the input point cloud dataset
* \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
*/
SampleConsensusModelNormalSphere (const PointCloudConstPtr &cloud,
bool random = false)
: SampleConsensusModelSphere<PointT> (cloud, random)
, SampleConsensusModelFromNormals<PointT, PointNT> ()
{
model_name_ = "SampleConsensusModelNormalSphere";
sample_size_ = 4;
model_size_ = 4;
}
/** \brief Constructor for base SampleConsensusModelNormalSphere.
* \param[in] cloud the input point cloud dataset
* \param[in] indices a vector of point indices to be used from \a cloud
* \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
*/
SampleConsensusModelNormalSphere (const PointCloudConstPtr &cloud,
const Indices &indices,
bool random = false)
: SampleConsensusModelSphere<PointT> (cloud, indices, random)
, SampleConsensusModelFromNormals<PointT, PointNT> ()
{
model_name_ = "SampleConsensusModelNormalSphere";
sample_size_ = 4;
model_size_ = 4;
}
/** \brief Empty destructor */
~SampleConsensusModelNormalSphere () override = default;
/** \brief Select all the points which respect the given model coefficients as inliers.
* \param[in] model_coefficients the coefficients of a sphere model that we need to compute distances to
* \param[in] threshold a maximum admissible distance threshold for determining the inliers from the outliers
* \param[out] inliers the resultant model inliers
*/
void
selectWithinDistance (const Eigen::VectorXf &model_coefficients,
const double threshold,
Indices &inliers) override;
/** \brief Count all the points which respect the given model coefficients as inliers.
* \param[in] model_coefficients the coefficients of a model that we need to compute distances to
* \param[in] threshold maximum admissible distance threshold for determining the inliers from the outliers
* \return the resultant number of inliers
*/
std::size_t
countWithinDistance (const Eigen::VectorXf &model_coefficients,
const double threshold) const override;
/** \brief Compute all distances from the cloud data to a given sphere model.
* \param[in] model_coefficients the coefficients of a sphere model that we need to compute distances to
* \param[out] distances the resultant estimated distances
*/
void
getDistancesToModel (const Eigen::VectorXf &model_coefficients,
std::vector<double> &distances) const override;
/** \brief Return a unique id for this model (SACMODEL_NORMAL_SPHERE). */
inline pcl::SacModel
getModelType () const override { return (SACMODEL_NORMAL_SPHERE); }
PCL_MAKE_ALIGNED_OPERATOR_NEW
protected:
using SampleConsensusModel<PointT>::sample_size_;
using SampleConsensusModel<PointT>::model_size_;
using SampleConsensusModelSphere<PointT>::isModelValid;
};
}
#ifdef PCL_NO_PRECOMPILE
#include <pcl/sample_consensus/impl/sac_model_normal_sphere.hpp>
#endif
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition point_cloud.h:173
pcl::SampleConsensusModelFromNormals
SampleConsensusModelFromNormals represents the base model class for models that require the use of su...
Definition sac_model.h:613
pcl::SampleConsensusModelFromNormals::normals_
PointCloudNConstPtr normals_
A pointer to the input dataset that contains the point normals of the XYZ dataset.
Definition sac_model.h:671
pcl::SampleConsensusModelFromNormals::PointCloudNConstPtr
typename pcl::PointCloud< PointNT >::ConstPtr PointCloudNConstPtr
Definition sac_model.h:615
pcl::SampleConsensusModelFromNormals::PointCloudNPtr
typename pcl::PointCloud< PointNT >::Ptr PointCloudNPtr
Definition sac_model.h:616
pcl::SampleConsensusModelFromNormals::normal_distance_weight_
double normal_distance_weight_
The relative weight (between 0 and 1) to give to the angular distance (0 to pi/2) between point norma...
Definition sac_model.h:666
pcl::SampleConsensusModel
SampleConsensusModel represents the base model class.
Definition sac_model.h:71
pcl::SampleConsensusModel::radius_max_
double radius_max_
Definition sac_model.h:565
pcl::SampleConsensusModel::radius_min_
double radius_min_
The minimum and maximum radius limits for the model.
Definition sac_model.h:565
pcl::SampleConsensusModel::sample_size_
unsigned int sample_size_
The size of a sample from which the model is computed.
Definition sac_model.h:589
pcl::SampleConsensusModel::PointCloudConstPtr
typename PointCloud::ConstPtr PointCloudConstPtr
Definition sac_model.h:74
pcl::SampleConsensusModel::indices_
IndicesPtr indices_
A pointer to the vector of point indices to use.
Definition sac_model.h:557
pcl::SampleConsensusModel::input_
PointCloudConstPtr input_
A boost shared pointer to the point cloud data array.
Definition sac_model.h:554
pcl::SampleConsensusModel::model_name_
std::string model_name_
The model name.
Definition sac_model.h:551
pcl::SampleConsensusModel::model_size_
unsigned int model_size_
The number of coefficients in the model.
Definition sac_model.h:592
pcl::SampleConsensusModel::PointCloudPtr
typename PointCloud::Ptr PointCloudPtr
Definition sac_model.h:75
pcl::SampleConsensusModel::error_sqr_dists_
std::vector< double > error_sqr_dists_
A vector holding the distances to the computed model.
Definition sac_model.h:586
pcl::SampleConsensusModelNormalSphere
SampleConsensusModelNormalSphere defines a model for 3D sphere segmentation using additional surface ...
Definition sac_model_normal_sphere.h:70
pcl::SampleConsensusModelNormalSphere::PointCloudNConstPtr
typename SampleConsensusModelFromNormals< PointT, PointNT >::PointCloudNConstPtr PointCloudNConstPtr
Definition sac_model_normal_sphere.h:86
pcl::SampleConsensusModelNormalSphere::ConstPtr
shared_ptr< const SampleConsensusModelNormalSphere< PointT, PointNT > > ConstPtr
Definition sac_model_normal_sphere.h:89
pcl::SampleConsensusModelNormalSphere::PointCloud
typename SampleConsensusModel< PointT >::PointCloud PointCloud
Definition sac_model_normal_sphere.h:81
pcl::SampleConsensusModelNormalSphere::~SampleConsensusModelNormalSphere
~SampleConsensusModelNormalSphere() override=default
Empty destructor.
pcl::SampleConsensusModelNormalSphere::Ptr
shared_ptr< SampleConsensusModelNormalSphere< PointT, PointNT > > Ptr
Definition sac_model_normal_sphere.h:88
pcl::SampleConsensusModelNormalSphere::selectWithinDistance
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.
Definition sac_model_normal_sphere.hpp:49
pcl::SampleConsensusModelNormalSphere::PointCloudNPtr
typename SampleConsensusModelFromNormals< PointT, PointNT >::PointCloudNPtr PointCloudNPtr
Definition sac_model_normal_sphere.h:85
pcl::SampleConsensusModelNormalSphere::SampleConsensusModelNormalSphere
SampleConsensusModelNormalSphere(const PointCloudConstPtr &cloud, bool random=false)
Constructor for base SampleConsensusModelNormalSphere.
Definition sac_model_normal_sphere.h:95
pcl::SampleConsensusModelNormalSphere::PointCloudPtr
typename SampleConsensusModel< PointT >::PointCloudPtr PointCloudPtr
Definition sac_model_normal_sphere.h:82
pcl::SampleConsensusModelNormalSphere::countWithinDistance
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.
Definition sac_model_normal_sphere.hpp:110
pcl::SampleConsensusModelNormalSphere::getDistancesToModel
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.
Definition sac_model_normal_sphere.hpp:161
pcl::SampleConsensusModelNormalSphere::getModelType
pcl::SacModel getModelType() const override
Return a unique id for this model (SACMODEL_NORMAL_SPHERE).
Definition sac_model_normal_sphere.h:153
pcl::SampleConsensusModelNormalSphere::PointCloudConstPtr
typename SampleConsensusModel< PointT >::PointCloudConstPtr PointCloudConstPtr
Definition sac_model_normal_sphere.h:83
pcl::SampleConsensusModelNormalSphere::SampleConsensusModelNormalSphere
SampleConsensusModelNormalSphere(const PointCloudConstPtr &cloud, const Indices &indices, bool random=false)
Constructor for base SampleConsensusModelNormalSphere.
Definition sac_model_normal_sphere.h:110
pcl::SampleConsensusModelSphere
SampleConsensusModelSphere defines a model for 3D sphere segmentation.
Definition sac_model_sphere.h:72
pcl::SampleConsensusModelSphere::isModelValid
bool isModelValid(const Eigen::VectorXf &model_coefficients) const override
Check whether a model is valid given the user constraints.
Definition sac_model_sphere.h:222
PCL_MAKE_ALIGNED_OPERATOR_NEW
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Definition memory.h:86
memory.h
Defines functions, macros and traits for allocating and using memory.
pcl
Definition convolution.h:46
pcl::SacModel
SacModel
Definition model_types.h:46
pcl::SACMODEL_NORMAL_SPHERE
@ SACMODEL_NORMAL_SPHERE
Definition model_types.h:59
pcl::Indices
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition types.h:133
pcl_macros.h
Defines all the PCL and non-PCL macros used.
pcl::PointXYZRGB
A point structure representing Euclidean xyz coordinates, and the RGB color.
Definition point_types.hpp:594