Skip to content

Commit

Permalink
feat: Add function to transform points along a single ray
Browse files Browse the repository at this point in the history
Solves issue #17
  • Loading branch information
TomSchammo committed Feb 15, 2024
1 parent c0ae0ec commit 5ebba3a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions LidarAug/cpp/include/transformations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,7 @@ _delete_labels_by_min_points(at::Tensor points, at::Tensor labels,
}

void random_point_noise(torch::Tensor points, float sigma);

void transform_along_ray(torch::Tensor points, float sigma);

#endif // !TRANSFORMATIONS_HPP
17 changes: 17 additions & 0 deletions LidarAug/cpp/src/transformations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,23 @@ void random_point_noise(torch::Tensor points, float sigma) {
}
}

void transform_along_ray(torch::Tensor points, float sigma) {
dimensions dims = {points.size(0), points.size(1), points.size(2)};

std::normal_distribution<float> dist(sigma, 0);

// TODO(tom): perf measure this
for (tensor_size_t i = 0; i < dims.batch_size; i++) {
for (tensor_size_t j = 0; j < dims.num_items; j++) {
const auto v = points[i][j].data_ptr<float>();
const auto noise = std::get<VALUE>(draw_values<float>(dist));
auto point_vector = f3{v[0], v[1], v[2]};

_random_point_noise(point_vector, noise);
}
}
}

#ifdef BUILD_MODULE
#undef TEST_RNG
#include "../include/bindings.hpp"
Expand Down

0 comments on commit 5ebba3a

Please sign in to comment.