Skip to content

Commit b3f3739

Browse files
author
theilerp
committed
bugfix in fpcs
- early termination using score threshold corrected - problem of openmp and rand usage solved
1 parent d3e4a49 commit b3f3739

File tree

1 file changed

+38
-32
lines changed

1 file changed

+38
-32
lines changed

registration/include/pcl/registration/impl/ia_fpcs.hpp

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -164,53 +164,59 @@ pcl::registration::FPCSInitialAlignment <PointSource, PointTarget, NormalT, Scal
164164
pcl::StopWatch timer;
165165

166166
#ifdef _OPENMP
167-
#pragma omp parallel for schedule (dynamic) num_threads (nr_threads_)
167+
#pragma omp parallel num_threads (nr_threads_)
168168
#endif
169-
170-
for (int i = 0; i < max_iterations_; i++)
171169
{
172-
173170
#ifdef _OPENMP
174-
#pragma omp flush (abort)
171+
std::srand (static_cast <unsigned int> (std::time (NULL)) ^ omp_get_thread_num ());
172+
#pragma omp for schedule (dynamic)
175173
#endif
174+
for (int i = 0; i < max_iterations_; i++)
175+
{
176+
177+
#ifdef _OPENMP
178+
#pragma omp flush (abort)
179+
#endif
176180

177-
MatchingCandidates candidates (1);
178-
std::vector <int> base_indices (4);
179-
float ratio[2];
180-
all_candidates [i] = candidates;
181+
MatchingCandidates candidates (1);
182+
std::vector <int> base_indices (4);
183+
float ratio[2];
184+
all_candidates[i] = candidates;
181185

182-
if (!abort)
183-
{
184-
// select four coplanar point base
185-
if (selectBase (base_indices, ratio) == 0)
186+
if (!abort)
186187
{
187-
// calculate candidate pair correspondences using diagonal lenghts of base
188-
pcl::Correspondences pairs_a, pairs_b;
189-
if (bruteForceCorrespondences (base_indices[0], base_indices[1], pairs_a) == 0 &&
190-
bruteForceCorrespondences (base_indices[2], base_indices[3], pairs_b) == 0)
188+
// select four coplanar point base
189+
if (selectBase (base_indices, ratio) == 0)
191190
{
192-
// determine candidate matches by combining pair correspondences based on segment distances
193-
std::vector <std::vector <int> > matches;
194-
if (determineBaseMatches (base_indices, matches, pairs_a, pairs_b, ratio) == 0)
191+
// calculate candidate pair correspondences using diagonal lenghts of base
192+
pcl::Correspondences pairs_a, pairs_b;
193+
if (bruteForceCorrespondences (base_indices[0], base_indices[1], pairs_a) == 0 &&
194+
bruteForceCorrespondences (base_indices[2], base_indices[3], pairs_b) == 0)
195195
{
196-
// check and evaluate candidate matches and store them
197-
handleMatches (base_indices, matches, candidates);
198-
if (candidates.size () != 0)
199-
all_candidates [i] = candidates;
196+
// determine candidate matches by combining pair correspondences based on segment distances
197+
std::vector <std::vector <int> > matches;
198+
if (determineBaseMatches (base_indices, matches, pairs_a, pairs_b, ratio) == 0)
199+
{
200+
// check and evaluate candidate matches and store them
201+
handleMatches (base_indices, matches, candidates);
202+
if (candidates.size () != 0)
203+
all_candidates[i] = candidates;
204+
}
200205
}
201206
}
202-
}
203207

204-
// check terminate early (time or fitness_score threshold reached)
205-
abort = (candidates.size () > 0 ? candidates[0].fitness_score < score_threshold_ : abort);
206-
abort = (abort ? abort : timer.getTimeSeconds () > max_runtime_);
208+
// check terminate early (time or fitness_score threshold reached)
209+
abort = (candidates.size () > 0 ? candidates[0].fitness_score < score_threshold_ : abort);
210+
abort = (abort ? abort : timer.getTimeSeconds () > max_runtime_);
207211

208212

209-
#ifdef _OPENMP
210-
#pragma omp flush (abort)
211-
#endif
213+
#ifdef _OPENMP
214+
#pragma omp flush (abort)
215+
#endif
216+
}
212217
}
213218
}
219+
214220

215221
// determine best match over all trys
216222
finalCompute (all_candidates);
@@ -301,7 +307,7 @@ pcl::registration::FPCSInitialAlignment <PointSource, PointTarget, NormalT, Scal
301307
}
302308

303309
// set further parameter
304-
if (score_threshold_ < FLT_MAX)
310+
if (score_threshold_ == FLT_MAX)
305311
score_threshold_ = 1.f - approx_overlap_;
306312

307313
if (max_iterations_ < 4)

0 commit comments

Comments
 (0)