Skip to content

Commit

Permalink
Merge pull request #58 from davidcaron/fix-downsampling-with-attribs
Browse files Browse the repository at this point in the history
Fix downsampling with attributes
  • Loading branch information
fwilliams authored Sep 10, 2023
2 parents cf0c166 + 9139fe1 commit fa5937e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/sample_point_cloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ struct AccumulatedPoint {
void AddPoint(const PointT& point, const AttribVecT& attrib) {
point_ += point;
if (attrib.cols() > 0) {
if (attrib_.cols() == 0) {
attrib_.resize(1, attrib.cols());
}
attrib_ += attrib;
}
num_of_points_ += 1;
Expand Down
1 change: 1 addition & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def test_downsample_point_cloud_on_voxel_grid(self):
self.assertEqual(nms.shape, pts.shape)
self.assertGreater(pts.shape[0], 0)
self.assertEqual(pts.shape[1], 3)
self.assertGreater(abs(nms[0, 0]), 1e-7)

# With RBG colors
c = np.random.rand(v.shape[0], 3)
Expand Down

0 comments on commit fa5937e

Please sign in to comment.