Skip to content

Commit

Permalink
change kd-tree search method from r-nearest to k-nereast to fix that …
Browse files Browse the repository at this point in the history
…r-nereast

search might not found enough points to calculate normals.
  • Loading branch information
symao committed Jan 16, 2018
1 parent c5ac7cc commit 5b9784e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/icpPointToPlane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ void IcpPointToPlane::computeNormal (const kdtree::KDTreeResultVector &neighbors
mu.val[0][0] += x;
mu.val[0][1] += y;
}

// zero mean
mu = mu/(double)neighbors.size();
Matrix Q = P - Matrix::ones(neighbors.size(),1)*mu;
Expand Down Expand Up @@ -369,8 +368,8 @@ double* IcpPointToPlane::computeNormals (const int32_t num_neighbors,const doubl
double *M_normal = (double*)malloc(m_kd_tree->N*m_dim*sizeof(double));
kdtree::KDTreeResultVector neighbors;
for (int32_t i=0; i<m_kd_tree->N; i++) {
//M_tree->n_nearest_around_point(i,0,num_neighbors,neighbors);
m_kd_tree->r_nearest_around_point(i,0,0.05,neighbors);
m_kd_tree->n_nearest_around_point(i,0,num_neighbors,neighbors);
// m_kd_tree->r_nearest_around_point(i,0,0.05,neighbors);
if (m_dim==2) computeNormal(neighbors,M_normal+i*2,flatness);
else computeNormal(neighbors,M_normal+i*3,flatness);
}
Expand Down

0 comments on commit 5b9784e

Please sign in to comment.