ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
Model.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
16 
17 namespace cloudViewer {
18 namespace t {
19 namespace pipelines {
20 namespace slam {
21 
25 class Model {
26 public:
27  Model() {}
28  Model(float voxel_size,
29  int block_resolution = 16,
30  int block_count = 1000,
31  const core::Tensor& T_init = core::Tensor::Eye(4,
33  core::Device("CPU:0")),
34  const core::Device& device = core::Device("CUDA:0"));
35 
37  void UpdateFramePose(int frame_id, const core::Tensor& T_frame_to_world) {
38  if (frame_id != frame_id_ + 1) {
39  utility::LogWarning("Skipped {} frames in update T!",
40  frame_id - (frame_id_ + 1));
41  }
42  frame_id_ = frame_id;
43  T_frame_to_world_ = T_frame_to_world.Contiguous();
44  }
45 
58  void SynthesizeModelFrame(Frame& raycast_frame,
59  float depth_scale = 1000.0,
60  float depth_min = 0.1,
61  float depth_max = 3.0,
62  float trunc_voxel_multiplier = 8.0,
63  bool enable_color = true,
64  float weight_threshold = -1.0);
65 
77  const Frame& input_frame,
78  const Frame& raycast_frame,
79  float depth_scale = 1000.0,
80  float depth_max = 3.0,
81  float depth_diff = 0.07,
83  const std::vector<odometry::OdometryConvergenceCriteria>& criteria =
84  {6, 3, 1});
85 
94  void Integrate(const Frame& input_frame,
95  float depth_scale = 1000.0,
96  float depth_max = 3.0,
97  float trunc_voxel_multiplier = 8.0f);
98 
105  t::geometry::PointCloud ExtractPointCloud(float weight_threshold = 3.0f,
106  int estimated_number = -1);
107 
114  t::geometry::TriangleMesh ExtractTriangleMesh(float weight_threshold = 3.0f,
115  int estimated_number = -1);
116 
119 
120 public:
123 
126 
130 
131  int frame_id_ = -1;
132 };
133 
134 } // namespace slam
135 } // namespace pipelines
136 } // namespace t
137 } // namespace cloudViewer
cloudViewer
Generic file read and write utility for python interface.
Definition: CloudViewerConfig.cpp:12
cloudViewer::t::pipelines::slam::Frame::SetData
void SetData(const std::string &name, const core::Tensor &data)
Definition: Frame.h:40
cloudViewer::core::UInt16
const Dtype UInt16
Definition: Dtype.cpp:49
cloudViewer::t::pipelines::slam::Model::frame_id_
int frame_id_
Definition: Model.h:131
cloudViewer::t::pipelines::odometry::Method
Method
Definition: RGBDOdometry.h:23
cloudViewer::t::pipelines::slam::Model::Model
Model()
Definition: Model.h:27
core::Tensor
cloudViewer::t::pipelines::slam::Model::voxel_grid_
t::geometry::VoxelBlockGrid voxel_grid_
Maintained volumetric map.
Definition: Model.h:122
cloudViewer::core::Tensor::Contiguous
Tensor Contiguous() const
Definition: Tensor.cpp:772
cloudViewer::t::geometry::InverseTransformation
core::Tensor InverseTransformation(const core::Tensor &T)
TODO(wei): find a proper place for such functionalities.
Definition: Utility.h:77
Utility.h
cloudViewer::t::geometry::VoxelBlockGrid::GetHashMap
core::HashMap GetHashMap()
Definition: VoxelBlockGrid.h:52
cloudViewer::core::HashMap
Definition: HashMap.h:23
VoxelBlockGrid.h
cloudViewer::t::geometry::Image
The Image class stores image with customizable rows, cols, channels, dtype and device.
Definition: Image.h:29
color
math::float4 color
Definition: LineSetBuffers.cpp:46
cloudViewer::t::pipelines::slam::Model::TrackFrameToModel
odometry::OdometryResult TrackFrameToModel(const Frame &input_frame, const Frame &raycast_frame, float depth_scale=1000.0, float depth_max=3.0, float depth_diff=0.07, odometry::Method method=odometry::Method::PointToPlane, const std::vector< odometry::OdometryConvergenceCriteria > &criteria={6, 3, 1})
Definition: Model.cpp:68
cloudViewer::t::pipelines::slam::Frame::GetWidth
int GetWidth() const
Definition: Frame.h:33
cloudViewer::t::pipelines::odometry::OdometryLossParams
Definition: RGBDOdometry.h:87
cloudViewer::t::geometry::PointCloud
A point cloud contains a list of 3D points.
Definition: PointCloud.h:82
cloudViewer::t::pipelines::odometry::OdometryResult
Definition: RGBDOdometry.h:59
cloudViewer::t::pipelines::slam::Frame::GetHeight
int GetHeight() const
Definition: Frame.h:32
cloudViewer::t::geometry::TriangleMesh
A triangle mesh contains vertices and triangles.
Definition: TriangleMesh.h:98
result
core::Tensor result
Definition: VtkUtils.cpp:76
cloudViewer::t::pipelines::slam::Frame::GetData
core::Tensor GetData(const std::string &name) const
Definition: Frame.h:43
cloudViewer::core::Tensor::Eye
static Tensor Eye(int64_t n, Dtype dtype, const Device &device)
Create an identity matrix of size n x n.
Definition: Tensor.cpp:418
RGBDImage.h
cloudViewer::t::pipelines::slam::Model::ExtractPointCloud
t::geometry::PointCloud ExtractPointCloud(float weight_threshold=3.0f, int estimated_number=-1)
Definition: Model.cpp:108
cloudViewer::t::geometry::VoxelBlockGrid::ExtractTriangleMesh
TriangleMesh ExtractTriangleMesh(float weight_threshold=3.0f, int estimated_vertex_numer=-1)
Definition: VoxelBlockGrid.cpp:437
cloudViewer::t::pipelines::slam::Model::GetHashMap
core::HashMap GetHashMap()
Get block hashmap int the VoxelBlockGrid.
Definition: Model.cpp:118
cloudViewer::t::pipelines::slam::Model
Definition: Model.h:25
cloudViewer::core::Device
Definition: Device.h:18
cloudViewer::t::geometry::VoxelBlockGrid::Integrate
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)
Definition: VoxelBlockGrid.cpp:293
cloudViewer::t::geometry::VoxelBlockGrid::ExtractPointCloud
PointCloud ExtractPointCloud(float weight_threshold=3.0f, int estimated_point_number=-1)
Definition: VoxelBlockGrid.cpp:405
cloudViewer::core::Float64
const Dtype Float64
Definition: Dtype.cpp:43
cloudViewer::t::geometry::VoxelBlockGrid
Definition: VoxelBlockGrid.h:26
cloudViewer::core::Float32
const Dtype Float32
Definition: Dtype.cpp:42
Frame.h
cloudViewer::t::pipelines::slam::Frame::GetDataAsImage
t::geometry::Image GetDataAsImage(const std::string &name) const
Definition: Frame.h:58
cloudViewer::t::geometry::VoxelBlockGrid::RayCast
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)
Definition: VoxelBlockGrid.cpp:329
cloudViewer::t::geometry::VoxelBlockGrid::GetUniqueBlockCoordinates
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)
Definition: VoxelBlockGrid.cpp:213
cloudViewer::t::pipelines::slam::Model::T_frame_to_world_
core::Tensor T_frame_to_world_
Definition: Model.h:129
Model.h
cloudViewer::t::pipelines::odometry::Method::PointToPlane
@ PointToPlane
cloudViewer::t::pipelines::slam::Model::UpdateFramePose
void UpdateFramePose(int frame_id, const core::Tensor &T_frame_to_world)
Definition: Model.h:37
cloudViewer::t::pipelines::slam::Model::ExtractTriangleMesh
t::geometry::TriangleMesh ExtractTriangleMesh(float weight_threshold=3.0f, int estimated_number=-1)
Definition: Model.cpp:113
std
Definition: Eigen.h:85
cloudViewer::core::Tensor::NumElements
int64_t NumElements() const
Definition: Tensor.h:1170
cloudViewer::t::pipelines::slam::Model::Integrate
void Integrate(const Frame &input_frame, float depth_scale=1000.0, float depth_max=3.0, float trunc_voxel_multiplier=8.0f)
Definition: Model.cpp:91
Image.h
Tensor.h
cloudViewer::t::pipelines::slam::Model::frustum_block_coords_
core::Tensor frustum_block_coords_
Active block coordinates from prior integration.
Definition: Model.h:125
LogWarning
#define LogWarning(...)
Definition: Logging.h:72
RGBDOdometry.h
cloudViewer::t::pipelines::slam::Frame::GetIntrinsics
core::Tensor GetIntrinsics() const
Definition: Frame.h:38
cloudViewer::t::pipelines::slam::Model::GetCurrentFramePose
core::Tensor GetCurrentFramePose() const
Definition: Model.h:36
cloudViewer::t::pipelines::slam::Frame
Frame is a container class storing an intrinsic matrix and several 2D tensors, from depth map,...
Definition: Frame.h:21
cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScale
OdometryResult RGBDOdometryMultiScale(const RGBDImage &source, const RGBDImage &target, const Tensor &intrinsics, const Tensor &init_source_to_target, const float depth_scale, const float depth_max, const std::vector< OdometryConvergenceCriteria > &criteria, const Method method, const OdometryLossParams &params)
Create an RGBD image pyramid given the original source and target RGBD images, and perform hierarchic...
Definition: RGBDOdometry.cpp:56
cloudViewer::t::pipelines::slam::Model::SynthesizeModelFrame
void SynthesizeModelFrame(Frame &raycast_frame, float depth_scale=1000.0, float depth_min=0.1, float depth_max=3.0, float trunc_voxel_multiplier=8.0, bool enable_color=true, float weight_threshold=-1.0)
Definition: Model.cpp:38
cloudViewer::t::geometry::RGBDImage
RGBDImage A pair of color and depth images.
Definition: RGBDImage.h:21
voxel_size
double voxel_size
Definition: VoxelGridIO.cpp:28