isl-org / Open3D

Open3D: A Modern Library for 3D Data Processing
http://www.open3d.org
Other
11.5k stars 2.31k forks source link

FarthestPointDownSample: starting with an index other than 0 #7049

Open abhishek47kashyap opened 1 week ago

abhishek47kashyap commented 1 week ago

Checklist

My Question

Looking at the implementation of PointCloud::FarthestPointDownSample() (linked down below for convenience), the downsampling always starts from points_[0] because farthest_index is initialized as 0. https://github.com/isl-org/Open3D/blob/fcc396e494dd3f1204e53571f37400cac50976ef/cpp/open3d/geometry/PointCloud.cpp#L509-L542

However, how could I start the downsampling from another index?

I could copy the implementation and modify the initial value of farthest_index to my desired index, but I wanted to ask if something already exists for this.

benjaminum commented 1 week ago

You could swap the point at index 0 with the point of your desired index and then call FarthestPointDownSample. Does this work for you?

abhishek47kashyap commented 1 week ago

swap the point at index 0 with the point of your desired index

That is indeed how I'm doing it right now

abhishek47kashyap commented 6 days ago

Would maintainers be in favor of providing the option to start from a specified index other than 0? I can take a shot at this then and open a PR

benjaminum commented 2 days ago

Can you explain how you use the feature? I just want to understand the use case better

abhishek47kashyap commented 2 days ago

Use case

I've got several camera poses (200+) looking at the same region/scene from different viewpoints. For every camera pose, I want to find n farthest viewpoints so as to get maximum "spread" for the scene. So my idea is that I can use the camera positions from the poses and run farthest point sampling, cycle through every camera position, and find the set of camera poses that are truly as far apart as they can be.

Admittedly, I'm not directly operating on a point cloud for this use case, but since I'm working with point clouds as part of the project anyway and therefore am already using Open3D, I thought I would create a "point cloud" out of the camera positions and use an Open3D functionality if available. I came across tools like fpsample but I'm not keen on bringing in a new dependency just for this one thing.

benjaminum commented 2 days ago

Looks like a really good example where setting the start index is needed. Looking forward to the PR!