Point Cloud Library (PCL)
1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
sample_consensus
impl
sac_model_parallel_plane.hpp
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Point Cloud Library (PCL) - www.pointclouds.org
5
* Copyright (c) 2010, Willow Garage, Inc.
6
* Copyright (c) 2012-, Open Perception, Inc.
7
*
8
* All rights reserved.
9
*
10
* Redistribution and use in source and binary forms, with or without
11
* modification, are permitted provided that the following conditions
12
* are met:
13
*
14
* * Redistributions of source code must retain the above copyright
15
* notice, this list of conditions and the following disclaimer.
16
* * Redistributions in binary form must reproduce the above
17
* copyright notice, this list of conditions and the following
18
* disclaimer in the documentation and/or other materials provided
19
* with the distribution.
20
* * Neither the name of the copyright holder(s) nor the names of its
21
* contributors may be used to endorse or promote products derived
22
* from this software without specific prior written permission.
23
*
24
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35
* POSSIBILITY OF SUCH DAMAGE.
36
*
37
* $Id$
38
a
39
*/
40
41
#ifndef PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_PARALLEL_PLANE_H_
42
#define PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_PARALLEL_PLANE_H_
43
44
#include <pcl/sample_consensus/sac_model_parallel_plane.h>
45
46
//////////////////////////////////////////////////////////////////////////
47
template
<
typename
Po
int
T>
void
48
pcl::SampleConsensusModelParallelPlane<PointT>::selectWithinDistance
(
49
const
Eigen::VectorXf &model_coefficients,
const
double
threshold,
Indices
&inliers)
50
{
51
// Check if the model is valid given the user constraints
52
if
(!
isModelValid
(model_coefficients))
53
{
54
inliers.clear ();
55
return
;
56
}
57
58
SampleConsensusModelPlane<PointT>::selectWithinDistance
(model_coefficients, threshold, inliers);
59
}
60
61
//////////////////////////////////////////////////////////////////////////
62
template
<
typename
Po
int
T> std::size_t
63
pcl::SampleConsensusModelParallelPlane<PointT>::countWithinDistance
(
64
const
Eigen::VectorXf &model_coefficients,
const
double
threshold)
const
65
{
66
// Check if the model is valid given the user constraints
67
if
(!
isModelValid
(model_coefficients))
68
{
69
return
(0);
70
}
71
72
return
(
SampleConsensusModelPlane<PointT>::countWithinDistance
(model_coefficients, threshold));
73
}
74
75
//////////////////////////////////////////////////////////////////////////
76
template
<
typename
Po
int
T>
void
77
pcl::SampleConsensusModelParallelPlane<PointT>::getDistancesToModel
(
78
const
Eigen::VectorXf &model_coefficients, std::vector<double> &
distances
)
const
79
{
80
// Check if the model is valid given the user constraints
81
if
(!
isModelValid
(model_coefficients))
82
{
83
distances
.clear ();
84
return
;
85
}
86
87
SampleConsensusModelPlane<PointT>::getDistancesToModel
(model_coefficients,
distances
);
88
}
89
90
//////////////////////////////////////////////////////////////////////////
91
template
<
typename
Po
int
T>
bool
92
pcl::SampleConsensusModelParallelPlane<PointT>::isModelValid
(
const
Eigen::VectorXf &model_coefficients)
const
93
{
94
if
(!
SampleConsensusModel<PointT>::isModelValid
(model_coefficients))
95
{
96
return
(
false
);
97
}
98
99
// Check against template, if given
100
if
(
eps_angle_
> 0.0)
101
{
102
// Obtain the plane normal
103
Eigen::Vector4f coeff = model_coefficients;
104
coeff[3] = 0.0f;
105
coeff.normalize ();
106
107
Eigen::Vector4f axis (
axis_
[0],
axis_
[1],
axis_
[2], 0.0f);
108
if
(std::abs (axis.dot (coeff)) >
sin_angle_
)
109
{
110
PCL_DEBUG (
"[pcl::SampleConsensusModelParallelPlane::isModelValid] Angle between plane normal and given axis is too large.\n"
);
111
return
(
false
);
112
}
113
}
114
115
return
(
true
);
116
}
117
118
#define PCL_INSTANTIATE_SampleConsensusModelParallelPlane(T) template class PCL_EXPORTS pcl::SampleConsensusModelParallelPlane<T>;
119
120
#endif
// PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_PARALLEL_PLANE_H_
121
pcl::SampleConsensusModel::isModelValid
virtual bool isModelValid(const Eigen::VectorXf &model_coefficients) const
Check whether a model is valid given the user constraints.
Definition
sac_model.h:528
pcl::SampleConsensusModelParallelPlane::isModelValid
bool isModelValid(const Eigen::VectorXf &model_coefficients) const override
Check whether a model is valid given the user constraints.
Definition
sac_model_parallel_plane.hpp:92
pcl::SampleConsensusModelParallelPlane::axis_
Eigen::Vector3f axis_
The axis along which we need to search for a plane perpendicular to.
Definition
sac_model_parallel_plane.h:178
pcl::SampleConsensusModelParallelPlane::eps_angle_
double eps_angle_
The maximum allowed difference between the plane and the given axis.
Definition
sac_model_parallel_plane.h:181
pcl::SampleConsensusModelParallelPlane::sin_angle_
double sin_angle_
The sine of the angle.
Definition
sac_model_parallel_plane.h:184
pcl::SampleConsensusModelParallelPlane::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_parallel_plane.hpp:63
pcl::SampleConsensusModelParallelPlane::getDistancesToModel
void getDistancesToModel(const Eigen::VectorXf &model_coefficients, std::vector< double > &distances) const override
Compute all distances from the cloud data to a given plane model.
Definition
sac_model_parallel_plane.hpp:77
pcl::SampleConsensusModelParallelPlane::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_parallel_plane.hpp:48
pcl::SampleConsensusModelPlane::getDistancesToModel
void getDistancesToModel(const Eigen::VectorXf &model_coefficients, std::vector< double > &distances) const override
Compute all distances from the cloud data to a given plane model.
Definition
sac_model_plane.hpp:122
pcl::SampleConsensusModelPlane::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_plane.hpp:153
pcl::SampleConsensusModelPlane::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_plane.hpp:191
pcl::distances
Definition
distances.h:50
pcl::Indices
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition
types.h:133