Skip to content

Commit

Permalink
testPoint: also return true when adding k-th neighbor
Browse files Browse the repository at this point in the history
I was perceiving occasional spikes in the computation time for
kNN search. This is due to the search box not being updated when
adding the k-th neighbor and subsequent iterations of the do-while
loop in kNN search never trigger the else case in testPoint. This
way we iterate over way too many points during search.
  • Loading branch information
Wannes Van Loock committed Jan 29, 2018
1 parent 2880ea1 commit ae742e9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions search/include/pcl/search/organized.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@ namespace pcl
float dist_z = point.z - query.z;
float squared_distance = dist_x * dist_x + dist_y * dist_y + dist_z * dist_z;
if (queue.size () < k)
{
queue.push (Entry (index, squared_distance));
return queue.size () == k;
}
else if (queue.top ().distance > squared_distance)
{
queue.pop ();
Expand Down

0 comments on commit ae742e9

Please sign in to comment.