Skip to content

Commit

Permalink
Speed up PPFRegistration by using a hash function with fewer collisio…
Browse files Browse the repository at this point in the history
…ns (#6223)

* speed_up_ppf_hash_search

* Update ppf_registration.h
  • Loading branch information
YeHuanjie authored Jan 21, 2025
1 parent 1590ba5 commit e787624
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions registration/include/pcl/registration/ppf_registration.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,18 @@ class PCL_EXPORTS PPFHashMapSearch {
std::size_t
operator()(const HashKeyStruct& s) const noexcept
{
const std::size_t h1 = std::hash<int>{}(s.first);
const std::size_t h2 = std::hash<int>{}(s.second.first);
const std::size_t h3 = std::hash<int>{}(s.second.second.first);
const std::size_t h4 = std::hash<int>{}(s.second.second.second);
return h1 ^ (h2 << 1) ^ (h3 << 2) ^ (h4 << 3);
/// RS hash function https://www.partow.net/programming/hashfunctions/index.html
std::size_t b_ = 378551;
std::size_t a_ = 63689;
std::size_t hash = 0;
hash = hash * a_ + s.first;
a_ = a_ * b_;
hash = hash * a_ + s.second.first;
a_ = a_ * b_;
hash = hash * a_ + s.second.second.first;
a_ = a_ * b_;
hash = hash * a_ + s.second.second.second;
return hash;
}
};
using FeatureHashMapType =
Expand Down

0 comments on commit e787624

Please sign in to comment.