Point Cloud Library (PCL)
1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
tracking
impl
approx_nearest_pair_point_cloud_coherence.hpp
1
#ifndef PCL_TRACKING_IMPL_APPROX_NEAREST_PAIR_POINT_CLOUD_COHERENCE_H_
2
#define PCL_TRACKING_IMPL_APPROX_NEAREST_PAIR_POINT_CLOUD_COHERENCE_H_
3
4
#include <pcl/search/octree.h>
5
#include <pcl/tracking/approx_nearest_pair_point_cloud_coherence.h>
6
7
namespace
pcl
{
8
namespace
tracking
{
9
template
<
typename
Po
int
InT>
10
void
11
ApproxNearestPairPointCloudCoherence<PointInT>::computeCoherence
(
12
const
PointCloudInConstPtr
& cloud,
const
IndicesConstPtr
&,
float
& w)
13
{
14
double
val = 0.0;
15
// for (std::size_t i = 0; i < indices->size (); i++)
16
for
(
const
auto
& point : *cloud) {
17
pcl::index_t
k_index = 0;
18
float
k_distance = 0.0;
19
// PointInT input_point = cloud->points[(*indices)[i]];
20
PointInT input_point = point;
21
search_
->approxNearestSearch(input_point, k_index, k_distance);
22
if
(k_distance <
maximum_distance_
*
maximum_distance_
) {
23
PointInT target_point = (*target_input_)[k_index];
24
double
coherence_val = 1.0;
25
for
(std::size_t i = 0; i <
point_coherences_
.size(); i++) {
26
PointCoherencePtr
coherence =
point_coherences_
[i];
27
double
w = coherence->compute(input_point, target_point);
28
coherence_val *= w;
29
}
30
val += coherence_val;
31
}
32
}
33
w = -
static_cast<
float
>
(val);
34
}
35
36
template
<
typename
Po
int
InT>
37
bool
38
ApproxNearestPairPointCloudCoherence<PointInT>::initCompute
()
39
{
40
if
(!
PointCloudCoherence<PointInT>::initCompute
()) {
41
PCL_ERROR(
"[pcl::%s::initCompute] PointCloudCoherence::Init failed.\n"
,
42
getClassName
().c_str());
43
// deinitCompute ();
44
return
(
false
);
45
}
46
47
// initialize tree
48
if
(!
search_
)
49
search_
.reset(
new
pcl::search::Octree<PointInT>
(0.01));
50
51
if
(
new_target_
&&
target_input_
) {
52
search_
->setInputCloud(
target_input_
);
53
new_target_
=
false
;
54
}
55
56
return
true
;
57
}
58
59
}
// namespace tracking
60
}
// namespace pcl
61
62
#define PCL_INSTANTIATE_ApproxNearestPairPointCloudCoherence(T) \
63
template class PCL_EXPORTS pcl::tracking::ApproxNearestPairPointCloudCoherence<T>;
64
65
#endif
pcl::search::Octree
search::Octree is a wrapper class which implements nearest neighbor search operations based on the pc...
Definition
octree.h:69
pcl::tracking::ApproxNearestPairPointCloudCoherence::search_
pcl::search::Octree< PointInT >::Ptr search_
Definition
approx_nearest_pair_point_cloud_coherence.h:51
pcl::tracking::ApproxNearestPairPointCloudCoherence::initCompute
bool initCompute() override
This method should get called before starting the actual computation.
Definition
approx_nearest_pair_point_cloud_coherence.hpp:38
pcl::tracking::ApproxNearestPairPointCloudCoherence::PointCoherencePtr
typename NearestPairPointCloudCoherence< PointInT >::PointCoherencePtr PointCoherencePtr
Definition
approx_nearest_pair_point_cloud_coherence.h:17
pcl::tracking::ApproxNearestPairPointCloudCoherence::PointCloudInConstPtr
typename NearestPairPointCloudCoherence< PointInT >::PointCloudInConstPtr PointCloudInConstPtr
Definition
approx_nearest_pair_point_cloud_coherence.h:19
pcl::tracking::ApproxNearestPairPointCloudCoherence::computeCoherence
void computeCoherence(const PointCloudInConstPtr &cloud, const IndicesConstPtr &indices, float &w_j) override
compute the nearest pairs and compute coherence using point_coherences_
Definition
approx_nearest_pair_point_cloud_coherence.hpp:11
pcl::tracking::NearestPairPointCloudCoherence::new_target_
bool new_target_
A flag which is true if target_input_ is updated.
Definition
nearest_pair_point_cloud_coherence.h:85
pcl::tracking::NearestPairPointCloudCoherence::maximum_distance_
double maximum_distance_
max of distance for points to be taken into account
Definition
nearest_pair_point_cloud_coherence.h:91
pcl::tracking::PointCloudCoherence::target_input_
PointCloudInConstPtr target_input_
a pointer to target point cloud
Definition
coherence.h:141
pcl::tracking::PointCloudCoherence::getClassName
const std::string & getClassName() const
Get a string representation of the name of this class.
Definition
coherence.h:132
pcl::tracking::PointCloudCoherence::initCompute
virtual bool initCompute()
This method should get called before starting the actual computation.
Definition
coherence.hpp:36
pcl::tracking::PointCloudCoherence::point_coherences_
std::vector< PointCoherencePtr > point_coherences_
a list of pointers to PointCoherence.
Definition
coherence.h:144
pcl::tracking
Definition
approx_nearest_pair_point_cloud_coherence.h:7
pcl
Definition
convolution.h:46
pcl::index_t
detail::int_type_t< detail::index_type_size, detail::index_type_signed > index_t
Type used for an index in PCL.
Definition
types.h:112
pcl::IndicesConstPtr
shared_ptr< const Indices > IndicesConstPtr
Definition
pcl_base.h:59