Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved performance of function geometry::PointCloud::RemoveRadiusOutliers, function geometry::ClusterDBSCAN and feature counting #6676

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cpp/open3d/geometry/PointCloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,8 @@ PointCloud::RemoveRadiusOutliers(size_t nb_points,
for (int i = 0; i < int(points_.size()); i++) {
std::vector<int> tmp_indices;
std::vector<double> dist;
size_t nb_neighbors = kdtree.SearchRadius(points_[i], search_radius,
size_t nb_neighbors = kdtree.SearchHybrid(points_[i], search_radius,
int(nb_points + 1),
tmp_indices, dist);
mask[i] = (nb_neighbors > nb_points);
++progress_bar;
Expand Down
26 changes: 9 additions & 17 deletions cpp/open3d/geometry/PointCloudCluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,33 +55,25 @@ std::vector<int> PointCloud::ClusterDBSCAN(double eps,
continue;
}

std::unordered_set<int> nbs_next(nbs[idx].begin(), nbs[idx].end());
std::unordered_set<int> nbs_visited;
nbs_visited.insert(int(idx));

labels[idx] = cluster_label;
++progress_bar;

std::vector<int> nbs_next(nbs[idx].begin() + 1, nbs[idx].end());

while (!nbs_next.empty()) {
int nb = *nbs_next.begin();
nbs_next.erase(nbs_next.begin());
nbs_visited.insert(nb);

// Noise label.
if (labels[nb] == -1) {
labels[nb] = cluster_label;
++progress_bar;
}
// Not undefined label.
if (labels[nb] != -2) {
int nb = nbs_next.back();
nbs_next.pop_back();

if (labels[nb] >= 0) {
continue;
}
labels[nb] = cluster_label;
++progress_bar;

if (nbs[nb].size() >= min_points) {
for (int qnb : nbs[nb]) {
if (nbs_visited.count(qnb) == 0) {
nbs_next.insert(qnb);
if (labels[qnb] < 0) {
nbs_next.push_back(qnb);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/open3d/pipelines/registration/Feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static Eigen::Vector4d ComputePairFeatures(const Eigen::Vector3d &p1,
auto n2_copy = n2;
double angle1 = n1_copy.dot(dp2p1) / result(3);
double angle2 = n2_copy.dot(dp2p1) / result(3);
if (acos(fabs(angle1)) > acos(fabs(angle2))) {
if (fabs(angle1) < fabs(angle2)) {
n1_copy = n2;
n2_copy = n1;
dp2p1 *= -1.0;
Expand Down
Loading