8 std::vector<Cluster>* clusters)
const {
9 const auto& cloud_data = input_cloud->data;
10 const size_t num_points = input_cloud->width * input_cloud->height;
11 if (num_points == 0) {
15 std::unordered_map<GridIndex, std::vector<size_t>> grid_map;
16 for (
size_t i = 0; i < num_points; ++i) {
19 if (x == 0.0f && y == 0.0f) {
28 grid_map[{gx, gy}].push_back(i);
31 std::unordered_map<GridIndex, bool> visited;
32 for (
const auto& [cell, points] : grid_map) {
38 std::queue<GridIndex> q;
40 std::vector<int> cluster_points;
46 auto it = grid_map.find(current);
47 if (it == grid_map.end()) {
51 for (
size_t idx : it->second) {
52 cluster_points.push_back(
static_cast<int>(idx));
55 for (
int dx = -1; dx <= 1; ++dx) {
56 for (
int dy = -1; dy <= 1; ++dy) {
57 if (dx == 0 && dy == 0) {
61 if (visited[neighbor]) {
64 if (grid_map.find(neighbor) != grid_map.end()) {
65 visited[neighbor] =
true;
71 clusters->push_back(
Cluster(input_cloud, cluster_points));
GridClustering(double grid_angle, double grid_radius, double start_augmentation, double radius_augmentation, double fov)
Constructor for the GridClustering algorithm.