Point Cloud Library (PCL) 1.15.0
Loading...
Searching...
No Matches
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
6namespace pcl {
7namespace tracking {
8//////////////////////////////////////////////////////////////////////////////////////////////
9template <typename PointInT, typename StateT>
10void
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//////////////////////////////////////////////////////////////////////////////////////////////
25template <typename PointInT, typename StateT>
26void
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++)
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;
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(
57 }
58 }
59 else
60 changed_ = false;
61 }
62 else {
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(
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++) {
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
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
PointCloudConstPtr input_
Definition pcl_base.h:147
unsigned int threads_
The number of threads the scheduler should use.
void setNumberOfThreads(unsigned int nr_threads=0)
Initialize the scheduler and set the number of threads to use.
void weight() override
weighting phase of particle filter method.
typename Tracker< PointInT, StateT >::PointCloudIn PointCloudIn
CloudCoherencePtr coherence_
A pointer to PointCloudCoherence.
bool testChangeDetection(const PointCloudInConstPtr &input)
Run change detection and return true if there is a change.
void computeTransformedPointCloudWithNormal(const StateT &hypothesis, pcl::Indices &indices, PointCloudIn &cloud)
Compute a reference pointcloud transformed to the pose that hypothesis represents and calculate indic...
bool changed_
A flag to be true when change of pointclouds is detected.
std::vector< PointCloudInPtr > transed_reference_vector_
A list of the pointers to pointclouds.
void computeTransformedPointCloudWithoutNormal(const StateT &hypothesis, PointCloudIn &cloud)
Compute a reference pointcloud transformed to the pose that hypothesis represents and calculate indic...
unsigned int change_counter_
A counter to skip change detection.
bool use_normal_
A flag to use normal or not.
void cropInputPointCloud(const PointCloudInConstPtr &cloud, PointCloudIn &output)
Crop the pointcloud by the bounding box calculated from hypothesis and the reference pointcloud.
PointCloudStatePtr particles_
A pointer to the particles.
unsigned int change_detector_interval_
The number of interval frame to run change detection.
int particle_num_
The number of the particles.
bool use_change_detector_
The flag which will be true if using change detection.
virtual void normalizeWeight()
Normalize the weights of all the particels.
shared_ptr< Indices > IndicesPtr
Definition pcl_base.h:58
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition types.h:133