Point Cloud Library (PCL)
1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
tracking
impl
kld_adaptive_particle_filter_omp.hpp
1
#ifndef PCL_TRACKING_IMPL_KLD_ADAPTIVE_PARTICLE_OMP_FILTER_H_
2
#define PCL_TRACKING_IMPL_KLD_ADAPTIVE_PARTICLE_OMP_FILTER_H_
3
4
#include <pcl/tracking/kld_adaptive_particle_filter_omp.h>
5
6
namespace
pcl
{
7
namespace
tracking
{
8
//////////////////////////////////////////////////////////////////////////////////////////////
9
template
<
typename
Po
int
InT,
typename
StateT>
10
void
11
KLDAdaptiveParticleFilterOMPTracker<PointInT, StateT>::setNumberOfThreads
(
12
unsigned
int
nr_threads)
13
{
14
if
(nr_threads == 0)
15
#ifdef _OPENMP
16
threads_
= omp_get_num_procs();
17
#else
18
threads_
= 1;
19
#endif
20
else
21
threads_
= nr_threads;
22
}
23
24
//////////////////////////////////////////////////////////////////////////////////////////////
25
template
<
typename
Po
int
InT,
typename
StateT>
26
void
27
KLDAdaptiveParticleFilterOMPTracker<PointInT, StateT>::weight
()
28
{
29
if
(!
use_normal_
) {
30
// clang-format off
31
#pragma omp parallel for \
32
default(none) \
33
num_threads(threads_)
34
// clang-format on
35
for
(
int
i = 0; i <
particle_num_
; i++)
36
this->
computeTransformedPointCloudWithoutNormal
((*
particles_
)[i],
37
*
transed_reference_vector_
[i]);
38
39
PointCloudInPtr
coherence_input(
new
PointCloudIn
);
40
this->
cropInputPointCloud
(
input_
, *coherence_input);
41
if
(
change_counter_
== 0) {
42
// test change detector
43
if
(!
use_change_detector_
|| this->
testChangeDetection
(coherence_input)) {
44
changed_
=
true
;
45
change_counter_
=
change_detector_interval_
;
46
coherence_
->setTargetCloud(coherence_input);
47
coherence_
->initCompute();
48
// clang-format off
49
#pragma omp parallel for \
50
default(none) \
51
num_threads(threads_)
52
// clang-format on
53
for
(
int
i = 0; i <
particle_num_
; i++) {
54
IndicesPtr
indices;
55
coherence_
->compute(
56
transed_reference_vector_
[i], indices, (*
particles_
)[i].
weight
);
57
}
58
}
59
else
60
changed_
=
false
;
61
}
62
else
{
63
--
change_counter_
;
64
coherence_
->setTargetCloud(coherence_input);
65
coherence_
->initCompute();
66
// clang-format off
67
#pragma omp parallel for \
68
default(none) \
69
num_threads(threads_)
70
// clang-format on
71
for
(
int
i = 0; i <
particle_num_
; i++) {
72
IndicesPtr
indices;
73
coherence_
->compute(
74
transed_reference_vector_
[i], indices, (*
particles_
)[i].
weight
);
75
}
76
}
77
}
78
else
{
79
std::vector<IndicesPtr> indices_list(
particle_num_
);
80
for
(
int
i = 0; i <
particle_num_
; i++) {
81
indices_list[i] =
IndicesPtr
(
new
pcl::Indices
);
82
}
83
// clang-format off
84
#pragma omp parallel for \
85
default(none) \
86
shared(indices_list) \
87
num_threads(threads_)
88
// clang-format on
89
for
(
int
i = 0; i <
particle_num_
; i++) {
90
this->
computeTransformedPointCloudWithNormal
(
91
(*
particles_
)[i], *indices_list[i], *
transed_reference_vector_
[i]);
92
}
93
94
PointCloudInPtr
coherence_input(
new
PointCloudIn
);
95
this->
cropInputPointCloud
(
input_
, *coherence_input);
96
97
coherence_
->setTargetCloud(coherence_input);
98
coherence_
->initCompute();
99
// clang-format off
100
#pragma omp parallel for \
101
default(none) \
102
shared(indices_list) \
103
num_threads(threads_)
104
// clang-format on
105
for
(
int
i = 0; i <
particle_num_
; i++) {
106
coherence_
->compute(
107
transed_reference_vector_
[i], indices_list[i], (*
particles_
)[i].
weight
);
108
}
109
}
110
111
normalizeWeight
();
112
}
113
}
// namespace tracking
114
}
// namespace pcl
115
116
#define PCL_INSTANTIATE_KLDAdaptiveParticleFilterOMPTracker(T, ST) \
117
template class PCL_EXPORTS pcl::tracking::KLDAdaptiveParticleFilterOMPTracker<T, ST>;
118
119
#endif
pcl::PCLBase< PointInT >::input_
PointCloudConstPtr input_
Definition
pcl_base.h:147
pcl::tracking::KLDAdaptiveParticleFilterOMPTracker::threads_
unsigned int threads_
The number of threads the scheduler should use.
Definition
kld_adaptive_particle_filter_omp.h:89
pcl::tracking::KLDAdaptiveParticleFilterOMPTracker::setNumberOfThreads
void setNumberOfThreads(unsigned int nr_threads=0)
Initialize the scheduler and set the number of threads to use.
Definition
kld_adaptive_particle_filter_omp.hpp:11
pcl::tracking::KLDAdaptiveParticleFilterOMPTracker::weight
void weight() override
weighting phase of particle filter method.
Definition
kld_adaptive_particle_filter_omp.hpp:27
pcl::tracking::KLDAdaptiveParticleFilterOMPTracker::PointCloudIn
typename Tracker< PointInT, StateT >::PointCloudIn PointCloudIn
Definition
kld_adaptive_particle_filter_omp.h:52
pcl::tracking::KLDAdaptiveParticleFilterOMPTracker::PointCloudInPtr
typename PointCloudIn::Ptr PointCloudInPtr
Definition
kld_adaptive_particle_filter_omp.h:53
pcl::tracking::ParticleFilterTracker::coherence_
CloudCoherencePtr coherence_
A pointer to PointCloudCoherence.
Definition
particle_filter.h:556
pcl::tracking::ParticleFilterTracker::testChangeDetection
bool testChangeDetection(const PointCloudInConstPtr &input)
Run change detection and return true if there is a change.
Definition
particle_filter.hpp:218
pcl::tracking::ParticleFilterTracker::computeTransformedPointCloudWithNormal
void computeTransformedPointCloudWithNormal(const StateT &hypothesis, pcl::Indices &indices, PointCloudIn &cloud)
Compute a reference pointcloud transformed to the pose that hypothesis represents and calculate indic...
Definition
particle_filter.hpp:298
pcl::tracking::ParticleFilterTracker::changed_
bool changed_
A flag to be true when change of pointclouds is detected.
Definition
particle_filter.h:615
pcl::tracking::ParticleFilterTracker::transed_reference_vector_
std::vector< PointCloudInPtr > transed_reference_vector_
A list of the pointers to pointclouds.
Definition
particle_filter.h:608
pcl::tracking::ParticleFilterTracker::computeTransformedPointCloudWithoutNormal
void computeTransformedPointCloudWithoutNormal(const StateT &hypothesis, PointCloudIn &cloud)
Compute a reference pointcloud transformed to the pose that hypothesis represents and calculate indic...
Definition
particle_filter.hpp:286
pcl::tracking::ParticleFilterTracker::change_counter_
unsigned int change_counter_
A counter to skip change detection.
Definition
particle_filter.h:618
pcl::tracking::ParticleFilterTracker::use_normal_
bool use_normal_
A flag to use normal or not.
Definition
particle_filter.h:589
pcl::tracking::ParticleFilterTracker::cropInputPointCloud
void cropInputPointCloud(const PointCloudInConstPtr &cloud, PointCloudIn &output)
Crop the pointcloud by the bounding box calculated from hypothesis and the reference pointcloud.
Definition
particle_filter.hpp:162
pcl::tracking::ParticleFilterTracker::particles_
PointCloudStatePtr particles_
A pointer to the particles.
Definition
particle_filter.h:553
pcl::tracking::ParticleFilterTracker::change_detector_interval_
unsigned int change_detector_interval_
The number of interval frame to run change detection.
Definition
particle_filter.h:626
pcl::tracking::ParticleFilterTracker::particle_num_
int particle_num_
The number of the particles.
Definition
particle_filter.h:541
pcl::tracking::ParticleFilterTracker::use_change_detector_
bool use_change_detector_
The flag which will be true if using change detection.
Definition
particle_filter.h:632
pcl::tracking::ParticleFilterTracker::normalizeWeight
virtual void normalizeWeight()
Normalize the weights of all the particels.
Definition
particle_filter.hpp:117
pcl::tracking
Definition
approx_nearest_pair_point_cloud_coherence.h:7
pcl
Definition
convolution.h:46
pcl::IndicesPtr
shared_ptr< Indices > IndicesPtr
Definition
pcl_base.h:58
pcl::Indices
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition
types.h:133