Point Cloud Library (PCL)
1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
tracking
impl
particle_filter_omp.hpp
1
#ifndef PCL_TRACKING_IMPL_PARTICLE_OMP_FILTER_H_
2
#define PCL_TRACKING_IMPL_PARTICLE_OMP_FILTER_H_
3
4
#include <pcl/tracking/particle_filter_omp.h>
5
6
namespace
pcl
{
7
namespace
tracking
{
8
//////////////////////////////////////////////////////////////////////////////////////////////
9
template
<
typename
Po
int
InT,
typename
StateT>
10
void
11
ParticleFilterOMPTracker<PointInT, StateT>::setNumberOfThreads
(
unsigned
int
nr_threads)
12
{
13
if
(nr_threads == 0)
14
#ifdef _OPENMP
15
threads_
= omp_get_num_procs();
16
#else
17
threads_
= 1;
18
#endif
19
else
20
threads_
= nr_threads;
21
}
22
23
//////////////////////////////////////////////////////////////////////////////////////////////
24
template
<
typename
Po
int
InT,
typename
StateT>
25
void
26
ParticleFilterOMPTracker<PointInT, StateT>::weight
()
27
{
28
if
(!
use_normal_
) {
29
// clang-format off
30
#pragma omp parallel for \
31
default(none) \
32
num_threads(threads_)
33
// clang-format on
34
for
(
int
i = 0; i <
particle_num_
; i++)
35
this->
computeTransformedPointCloudWithoutNormal
((*
particles_
)[i],
36
*
transed_reference_vector_
[i]);
37
38
PointCloudInPtr
coherence_input(
new
PointCloudIn
);
39
this->
cropInputPointCloud
(
input_
, *coherence_input);
40
if
(
change_counter_
== 0) {
41
// test change detector
42
if
(!
use_change_detector_
|| this->
testChangeDetection
(coherence_input)) {
43
changed_
=
true
;
44
change_counter_
=
change_detector_interval_
;
45
coherence_
->setTargetCloud(coherence_input);
46
coherence_
->initCompute();
47
// clang-format off
48
#pragma omp parallel for \
49
default(none) \
50
num_threads(threads_)
51
// clang-format on
52
for
(
int
i = 0; i <
particle_num_
; i++) {
53
IndicesPtr
indices;
// dummy
54
coherence_
->compute(
55
transed_reference_vector_
[i], indices, (*
particles_
)[i].
weight
);
56
}
57
}
58
else
59
changed_
=
false
;
60
}
61
else
{
62
--
change_counter_
;
63
coherence_
->setTargetCloud(coherence_input);
64
coherence_
->initCompute();
65
// clang-format off
66
#pragma omp parallel for \
67
default(none) \
68
num_threads(threads_)
69
// clang-format on
70
for
(
int
i = 0; i <
particle_num_
; i++) {
71
IndicesPtr
indices;
// dummy
72
coherence_
->compute(
73
transed_reference_vector_
[i], indices, (*
particles_
)[i].
weight
);
74
}
75
}
76
}
77
else
{
78
std::vector<IndicesPtr> indices_list(
particle_num_
);
79
for
(
int
i = 0; i <
particle_num_
; i++) {
80
indices_list[i] =
IndicesPtr
(
new
pcl::Indices
);
81
}
82
// clang-format off
83
#pragma omp parallel for \
84
default(none) \
85
shared(indices_list) \
86
num_threads(threads_)
87
// clang-format on
88
for
(
int
i = 0; i <
particle_num_
; i++) {
89
this->
computeTransformedPointCloudWithNormal
(
90
(*
particles_
)[i], *indices_list[i], *
transed_reference_vector_
[i]);
91
}
92
93
PointCloudInPtr
coherence_input(
new
PointCloudIn
);
94
this->
cropInputPointCloud
(
input_
, *coherence_input);
95
96
coherence_
->setTargetCloud(coherence_input);
97
coherence_
->initCompute();
98
// clang-format off
99
#pragma omp parallel for \
100
default(none) \
101
shared(indices_list) \
102
num_threads(threads_)
103
// clang-format on
104
for
(
int
i = 0; i <
particle_num_
; i++) {
105
coherence_
->compute(
106
transed_reference_vector_
[i], indices_list[i], (*
particles_
)[i].
weight
);
107
}
108
}
109
110
normalizeWeight
();
111
}
112
}
// namespace tracking
113
}
// namespace pcl
114
115
#define PCL_INSTANTIATE_ParticleFilterOMPTracker(T, ST) \
116
template class PCL_EXPORTS pcl::tracking::ParticleFilterOMPTracker<T, ST>;
117
118
#endif
pcl::PCLBase< PointInT >::input_
PointCloudConstPtr input_
Definition
pcl_base.h:147
pcl::tracking::ParticleFilterOMPTracker::PointCloudInPtr
typename PointCloudIn::Ptr PointCloudInPtr
Definition
particle_filter_omp.h:41
pcl::tracking::ParticleFilterOMPTracker::weight
void weight() override
weighting phase of particle filter method.
Definition
particle_filter_omp.hpp:26
pcl::tracking::ParticleFilterOMPTracker::PointCloudIn
typename Tracker< PointInT, StateT >::PointCloudIn PointCloudIn
Definition
particle_filter_omp.h:40
pcl::tracking::ParticleFilterOMPTracker::threads_
unsigned int threads_
The number of threads the scheduler should use.
Definition
particle_filter_omp.h:77
pcl::tracking::ParticleFilterOMPTracker::setNumberOfThreads
void setNumberOfThreads(unsigned int nr_threads=0)
Initialize the scheduler and set the number of threads to use.
Definition
particle_filter_omp.hpp:11
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