Skip to content

Commit

Permalink
ICP/intensity: Applying fix from #1111
Browse files Browse the repository at this point in the history
  • Loading branch information
matlabbe committed Aug 13, 2023
1 parent 6d36fc1 commit cdd8cd9
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions corelib/src/icp/libpointmatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -513,16 +513,28 @@ struct KDTreeMatcherIntensity : public PointMatcher<T>::Matcher
for (int i = 0; i < pointsCount; ++i)
{
float minDistance = std::numeric_limits<float>::max();
bool minDistFound = false;
for(int k=0; k<knn && k<filteredReferenceIntensity.rows(); ++k)
{
float distIntensity = fabs(filteredReadingIntensity(0,i) - filteredReferenceIntensity(0, matches.ids.coeff(k, i)));
if(distIntensity < minDistance)
int matchesIdsCoeff = matches.ids.coeff(k, i);
if (matchesIdsCoeff!=-1)
{
matchesOrderedByIntensity.ids.coeffRef(0, i) = matches.ids.coeff(k, i);
matchesOrderedByIntensity.dists.coeffRef(0, i) = matches.dists.coeff(k, i);
minDistance = distIntensity;
float distIntensity = fabs(filteredReadingIntensity(0,i) - filteredReferenceIntensity(0, matchesIdsCoeff));
if(distIntensity < minDistance)
{
matchesOrderedByIntensity.ids.coeffRef(0, i) = matches.ids.coeff(k, i);
matchesOrderedByIntensity.dists.coeffRef(0, i) = matches.dists.coeff(k, i);
minDistance = distIntensity;
minDistFound = true;
}
}
}

if (!minDistFound)
{
matchesOrderedByIntensity.ids.coeffRef(0, i) = matches.ids.coeff(0, i);
matchesOrderedByIntensity.dists.coeffRef(0, i) = matches.dists.coeff(0, i);
}
}
matches = matchesOrderedByIntensity;
}
Expand Down

0 comments on commit cdd8cd9

Please sign in to comment.