Function ouster::sdk::core::voxel_downsample_xd

Function Documentation

AttributedPointCloud ouster::sdk::core::voxel_downsample_xd(const Eigen::Ref<const ArrayX3dR> &xyz, double voxel_size, std::size_t max_points_per_voxel = VoxelHashMap::DEFAULT_MAX_POINTS_PER_VOXEL, std::size_t min_points_per_voxel = VoxelHashMap::DEFAULT_MIN_POINTS_PER_VOXEL, VoxelDownsampleStrategy strategy = VoxelHashMap::DEFAULT_STRATEGY, const AttributeLayout &attribute_layout = AttributeLayout(), const Eigen::Ref<const AttributeRecords> &records = AttributeRecords(), VHMInternalStorageMode internal_storage_mode = VoxelHashMap::DEFAULT_INTERNAL_STORAGE_MODE, std::size_t attribute_index = 0)

Downsample a pointcloud, optionally with attributes that keep their own types.

Points go in as positions plus packed attribute records described by attribute_layout, and come back the same way, so e.g. a uint32 RANGE or uint8 REFLECTIVITY is never widened to double. With VoxelDownsampleStrategy::AVERAGE_POINT the per-voxel mean of an integer attribute is rounded to the nearest representable value. With SMALLEST or LARGEST, attribute_layout must not be empty, and the points kept per voxel are the ones with the smallest, respectively largest, value of the scalar attribute named by attribute_index. Leave attribute_layout and records out (or empty) to downsample positions only. Such input goes through the same path as attributed input; use voxel_downsample() to have it sent to voxel_downsample_3d() instead.

The parameters follow VoxelHashMap::create(), with the same defaults. The records ride next to the attribute_layout describing them; create() has no records, and voxel_downsample_xd() has no max_distance, since downsampling never trims.

Parameters:
  • xyz[in] Row-major Nx3 array of point positions.

  • voxel_size[in] Edge length of each cubic voxel.

  • max_points_per_voxel[in] Maximum points kept per voxel (FIRST_N_POINT, LAST_N_POINT, RANDOM).

  • min_points_per_voxel[in] Minimum insertions before a voxel contributes.

  • strategy[in] The VoxelDownsampleStrategy selecting the per-voxel reduction.

  • attribute_layout[in] Types and widths of the per-point attributes; empty for positions only.

  • records[in] xyz.rows() x attribute_layout.stride() packed attribute records, one row per point; empty when attribute_layout is.

  • internal_storage_mode[in] How points are stored inside the voxels. AUTO picks fixed point for small voxels, which returns kept positions within a small fraction of the voxel size of the input; ABS returns them exactly.

  • attribute_index[in] Index into attribute_layout of the scalar attribute to rank by; ignored unless strategy is SMALLEST or LARGEST, where it must name a scalar attribute.

Throws:

std::invalid_argument – if records is not xyz.rows() x attribute_layout.stride() (any records given without a layout included), for a non-positive voxel_size, a zero max_points_per_voxel, or an unknown strategy, or (SMALLEST/LARGEST only) an empty attribute_layout or an attribute_index that does not name a scalar attribute of it.

Returns:

The downsampled points, their records, and attribute_layout.