Point Cloud Library (PCL) 1.15.0
Loading...
Searching...
No Matches
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
6namespace pcl {
7namespace tracking {
8//////////////////////////////////////////////////////////////////////////////////////////////
9template <typename PointInT, typename StateT>
10void
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//////////////////////////////////////////////////////////////////////////////////////////////
24template <typename PointInT, typename StateT>
25void
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++)
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;
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(
56 }
57 }
58 else
59 changed_ = false;
60 }
61 else {
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(
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++) {
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
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
PointCloudConstPtr input_
Definition pcl_base.h:147
void weight() override
weighting phase of particle filter method.
typename Tracker< PointInT, StateT >::PointCloudIn PointCloudIn
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.
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