Open3D (C++ API)
0.18.0
|
#include <VoxelBlockGrid.h>
Public Member Functions | |
VoxelBlockGrid ()=default | |
VoxelBlockGrid (const std::vector< std::string > &attr_names, const std::vector< core::Dtype > &attr_dtypes, const std::vector< core::SizeVector > &attr_channels, float voxel_size=0.0058, int64_t block_resolution=16, int64_t block_count=10000, const core::Device &device=core::Device("CPU:0"), const core::HashBackendType &backend=core::HashBackendType::Default) | |
Default Constructor. Example: VoxelBlockGrid({"tsdf", "weight", "color"}, {core::Float32, core::UInt16, core::UInt16}, {{1}, {1}, {3}}, 0.005, 16, 10000, core::Device("CUDA:0"), core::HashBackendType::Default);. More... | |
core::HashMap | GetHashMap () |
core::Tensor | GetAttribute (const std::string &attr_name) const |
core::Tensor | GetVoxelIndices (const core::Tensor &buf_indices) const |
core::Tensor | GetVoxelIndices () const |
Get all active voxel indices. More... | |
core::Tensor | GetVoxelCoordinates (const core::Tensor &voxel_indices) const |
std::pair< core::Tensor, core::Tensor > | GetVoxelCoordinatesAndFlattenedIndices (const core::Tensor &buf_indices) |
std::pair< core::Tensor, core::Tensor > | GetVoxelCoordinatesAndFlattenedIndices () |
core::Tensor | GetUniqueBlockCoordinates (const Image &depth, const core::Tensor &intrinsic, const core::Tensor &extrinsic, float depth_scale=1000.0f, float depth_max=3.0f, float trunc_voxel_multiplier=8.0) |
core::Tensor | GetUniqueBlockCoordinates (const PointCloud &pcd, float trunc_voxel_multiplier=8.0) |
Obtain active block coordinates from a point cloud. More... | |
void | Integrate (const core::Tensor &block_coords, const Image &depth, const Image &color, const core::Tensor &depth_intrinsic, const core::Tensor &color_intrinsic, const core::Tensor &extrinsic, float depth_scale=1000.0f, float depth_max=3.0f, float trunc_voxel_multiplier=8.0f) |
void | Integrate (const core::Tensor &block_coords, const Image &depth, const Image &color, const core::Tensor &intrinsic, const core::Tensor &extrinsic, float depth_scale=1000.0f, float depth_max=3.0f, float trunc_voxel_multiplier=8.0f) |
void | Integrate (const core::Tensor &block_coords, const Image &depth, const core::Tensor &intrinsic, const core::Tensor &extrinsic, float depth_scale=1000.0f, float depth_max=3.0f, float trunc_voxel_multiplier=8.0f) |
TensorMap | RayCast (const core::Tensor &block_coords, const core::Tensor &intrinsic, const core::Tensor &extrinsic, int width, int height, const std::vector< std::string > attrs={"depth", "color"}, float depth_scale=1000.0f, float depth_min=0.1f, float depth_max=3.0f, float weight_threshold=3.0f, float trunc_voxel_multiplier=8.0f, int range_map_down_factor=8) |
PointCloud | ExtractPointCloud (float weight_threshold=3.0f, int estimated_point_number=-1) |
TriangleMesh | ExtractTriangleMesh (float weight_threshold=3.0f, int estimated_vertex_numer=-1) |
void | Save (const std::string &file_name) const |
Save a voxel block grid to a .npz file. More... | |
VoxelBlockGrid | To (const core::Device &device, bool copy=false) const |
Convert the hash map to another device. More... | |
Static Public Member Functions | |
static VoxelBlockGrid | Load (const std::string &file_name) |
Load a voxel block grid from a .npz file. More... | |
A voxel block grid is a sparse grid of voxel blocks. Each voxel block is a dense 3D array, preserving local data distribution. If the block_resolution is set to 1, then the VoxelBlockGrid degenerates to a sparse voxel grid.
|
default |
open3d::t::geometry::VoxelBlockGrid::VoxelBlockGrid | ( | const std::vector< std::string > & | attr_names, |
const std::vector< core::Dtype > & | attr_dtypes, | ||
const std::vector< core::SizeVector > & | attr_channels, | ||
float | voxel_size = 0.0058 , |
||
int64_t | block_resolution = 16 , |
||
int64_t | block_count = 10000 , |
||
const core::Device & | device = core::Device("CPU:0") , |
||
const core::HashBackendType & | backend = core::HashBackendType::Default |
||
) |
Default Constructor. Example: VoxelBlockGrid({"tsdf", "weight", "color"}, {core::Float32, core::UInt16, core::UInt16}, {{1}, {1}, {3}}, 0.005, 16, 10000, core::Device("CUDA:0"), core::HashBackendType::Default);.
PointCloud open3d::t::geometry::VoxelBlockGrid::ExtractPointCloud | ( | float | weight_threshold = 3.0f , |
int | estimated_point_number = -1 |
||
) |
Specific operation for TSDF volumes. Extract point cloud at isosurface points. Weight threshold is used to filter outliers. By default we use 3.0, where we assume a reliable surface point comes from the fusion of at least 3 viewpoints. Use as low as 0.0 to accept all the possible observations. Estimated point numbers optionally speeds up the process by a one-pass extraction with pre-allocated buffers. Use -1 when no estimate is available.
TriangleMesh open3d::t::geometry::VoxelBlockGrid::ExtractTriangleMesh | ( | float | weight_threshold = 3.0f , |
int | estimated_vertex_numer = -1 |
||
) |
Specific operation for TSDF volumes. Extract mesh near iso-surfaces with Marching Cubes. Weight threshold is used to filter outliers. By default we use 3.0, where we assume a reliable surface point comes from the fusion of at least 3 viewpoints. Use as low as 0.0 to accept all the possible observations. Estimated point numbers optionally speeds up the process by a one-pass extraction with pre-allocated buffers. Use -1 when no estimate is available.
core::Tensor open3d::t::geometry::VoxelBlockGrid::GetAttribute | ( | const std::string & | attr_name | ) | const |
Get the attribute tensor corresponding to the attribute name. A sugar for hashmap.GetValueTensor(i)
|
inline |
Get the underlying hash map that stores values in structure of arrays (SoA).
core::Tensor open3d::t::geometry::VoxelBlockGrid::GetUniqueBlockCoordinates | ( | const Image & | depth, |
const core::Tensor & | intrinsic, | ||
const core::Tensor & | extrinsic, | ||
float | depth_scale = 1000.0f , |
||
float | depth_max = 3.0f , |
||
float | trunc_voxel_multiplier = 8.0 |
||
) |
Get a (3, M) active block coordinates from a depth image, with potential duplicates removed. Note: these coordinates are not activated in the internal sparse voxel block. They need to be inserted in the hash map.
core::Tensor open3d::t::geometry::VoxelBlockGrid::GetUniqueBlockCoordinates | ( | const PointCloud & | pcd, |
float | trunc_voxel_multiplier = 8.0 |
||
) |
Obtain active block coordinates from a point cloud.
core::Tensor open3d::t::geometry::VoxelBlockGrid::GetVoxelCoordinates | ( | const core::Tensor & | voxel_indices | ) | const |
Get a (3, hashmap.Size() * resolution^3) coordinate tensor of active voxels per block, used for geometry transformation jointly with indices from GetVoxelIndices.
Example: For a voxel block grid with (2, 2, 2) block resolution, if the active block coordinates are {(-1, 3, 2), (0, 2, 4)}, the returned result will be a (3, 2 x 8) tensor given by: { key_tensor[voxel_indices[0]] * block_resolution_ + voxel_indices[1] key_tensor[voxel_indices[0]] * block_resolution_ + voxel_indices[2] key_tensor[voxel_indices[0]] * block_resolution_ + voxel_indices[3] } Note: the coordinates are VOXEL COORDINATES in Int64. To access metric coordinates, multiply by voxel size.
std::pair< core::Tensor, core::Tensor > open3d::t::geometry::VoxelBlockGrid::GetVoxelCoordinatesAndFlattenedIndices | ( | ) |
Same as above, but N is the number of all the active voxels with blocks stored in the hash map.
std::pair< core::Tensor, core::Tensor > open3d::t::geometry::VoxelBlockGrid::GetVoxelCoordinatesAndFlattenedIndices | ( | const core::Tensor & | buf_indices | ) |
Accelerated combination of GetVoxelIndices and GetVoxelCoordinates. Returns a (N, 3) coordinate in float, and a (N, ) flattened index tensor, where N is the number of active voxels located at buf_indices.
core::Tensor open3d::t::geometry::VoxelBlockGrid::GetVoxelIndices | ( | ) | const |
Get all active voxel indices.
core::Tensor open3d::t::geometry::VoxelBlockGrid::GetVoxelIndices | ( | const core::Tensor & | buf_indices | ) | const |
Get a (4, N), Int64 index tensor for active voxels, used for advanced indexing. Returned index tensor can access selected value buffers in order of (buf_index, index_voxel_x, index_voxel_y, index_voxel_z).
Example: For a voxel block grid with (2, 2, 2) block resolution, if the active block coordinates are at buffer index {(2, 4)} given by GetActiveIndices() from the underlying hash map, the returned result will be a (4, 2 x 8) tensor: { (2, 0, 0, 0), (2, 1, 0, 0), (2, 0, 1, 0), (2, 1, 1, 0), (2, 0, 0, 1), (2, 1, 0, 1), (2, 0, 1, 1), (2, 1, 1, 1), (4, 0, 0, 0), (4, 1, 0, 0), (4, 0, 1, 0), (4, 1, 1, 0), (4, 0, 0, 1), (4, 1, 0, 1), (4, 0, 1, 1), (4, 1, 1, 1), } Note: the slicing order is z-y-x.
TODO: Check if kernel version is necessary.
operator % is not supported now
void open3d::t::geometry::VoxelBlockGrid::Integrate | ( | const core::Tensor & | block_coords, |
const Image & | depth, | ||
const core::Tensor & | intrinsic, | ||
const core::Tensor & | extrinsic, | ||
float | depth_scale = 1000.0f , |
||
float | depth_max = 3.0f , |
||
float | trunc_voxel_multiplier = 8.0f |
||
) |
Specific operation for TSDF volumes. Similar to RGB-D integration, but only applied to depth.
void open3d::t::geometry::VoxelBlockGrid::Integrate | ( | const core::Tensor & | block_coords, |
const Image & | depth, | ||
const Image & | color, | ||
const core::Tensor & | depth_intrinsic, | ||
const core::Tensor & | color_intrinsic, | ||
const core::Tensor & | extrinsic, | ||
float | depth_scale = 1000.0f , |
||
float | depth_max = 3.0f , |
||
float | trunc_voxel_multiplier = 8.0f |
||
) |
Specific operation for TSDF volumes. Integrate an RGB-D frame in the selected block coordinates using pinhole camera model. For built-in kernels, we support efficient hash map types for SLAM: tsdf: float, weight: uint16_t, color: uint16_t and accurate mode for differentiable rendering: tsdf/weight/color: float We assume input data are either raw: depth: uint16_t, color: uint8_t or depth/color: float. To support other types and properties, users should combine GetUniqueBlockCoordinates, GetVoxelIndices, and GetVoxelCoordinates, with self-defined operations.
void open3d::t::geometry::VoxelBlockGrid::Integrate | ( | const core::Tensor & | block_coords, |
const Image & | depth, | ||
const Image & | color, | ||
const core::Tensor & | intrinsic, | ||
const core::Tensor & | extrinsic, | ||
float | depth_scale = 1000.0f , |
||
float | depth_max = 3.0f , |
||
float | trunc_voxel_multiplier = 8.0f |
||
) |
Specific operation for TSDF volumes. Similar to RGB-D integration, but uses the same intrinsics for depth and color.
|
static |
Load a voxel block grid from a .npz file.
TensorMap open3d::t::geometry::VoxelBlockGrid::RayCast | ( | const core::Tensor & | block_coords, |
const core::Tensor & | intrinsic, | ||
const core::Tensor & | extrinsic, | ||
int | width, | ||
int | height, | ||
const std::vector< std::string > | attrs = {"depth", "color"} , |
||
float | depth_scale = 1000.0f , |
||
float | depth_min = 0.1f , |
||
float | depth_max = 3.0f , |
||
float | weight_threshold = 3.0f , |
||
float | trunc_voxel_multiplier = 8.0f , |
||
int | range_map_down_factor = 8 |
||
) |
Specific operation for TSDF volumes. Perform volumetric ray casting in the selected block coordinates. Return selected properties from the frame. Supported attributes: Conventional rendering: vertex, depth, color, normal, range Differentiable rendering (voxel-wise): mask, index, (interpolation) ratio. The block coordinates in the frustum can be taken from GetUniqueBlockCoordinates. All the block coordinates can be taken from GetHashMap().GetKeyTensor().
void open3d::t::geometry::VoxelBlockGrid::Save | ( | const std::string & | file_name | ) | const |
Save a voxel block grid to a .npz file.
VoxelBlockGrid open3d::t::geometry::VoxelBlockGrid::To | ( | const core::Device & | device, |
bool | copy = false |
||
) | const |
Convert the hash map to another device.