ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ControlGrid.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 
15 
16 namespace cloudViewer {
17 namespace t {
18 namespace pipelines {
19 namespace slac {
20 
30 class ControlGrid {
31 public:
34  static const std::string kGrid8NbIndices;
36  static const std::string kGrid8NbVertexInterpRatios;
38  static const std::string kGrid8NbNormalInterpRatios;
39 
41  ControlGrid() = default;
42 
44  ControlGrid(float grid_size,
45  int64_t grid_count = 1000,
46  const core::Device& device = core::Device("CPU:0"));
47 
50  ControlGrid(float grid_size,
51  const core::Tensor& keys,
52  const core::Tensor& values,
53  const core::Device& device = core::Device("CPU:0"));
54 
56  void Touch(const geometry::PointCloud& pcd);
57 
60  void Compactify();
61 
69  std::tuple<core::Tensor, core::Tensor, core::Tensor> GetNeighborGridMap();
70 
79 
82 
88  const core::Tensor& intrinsics,
89  const core::Tensor& extrinsics,
90  float depth_scale,
91  float depth_max);
92 
98  const core::Tensor& intrinsics,
99  const core::Tensor& extrinsics,
100  float depth_scale,
101  float depth_max);
102 
105  return ctr_hashmap_->GetKeyTensor().To(core::Float32) * grid_size_;
106  }
107 
110  core::Tensor GetCurrPositions() { return ctr_hashmap_->GetValueTensor(); }
111 
112  std::shared_ptr<core::HashMap> GetHashMap() { return ctr_hashmap_; }
113  int64_t Size() { return ctr_hashmap_->Size(); }
114 
115  core::Device GetDevice() { return device_; }
116  int64_t GetAnchorIdx() { return anchor_idx_; }
117 
118 private:
120  int64_t anchor_idx_ = 0;
121 
123  float grid_size_;
124 
125  core::Device device_ = core::Device("CPU:0");
126  std::shared_ptr<core::HashMap> ctr_hashmap_;
127 };
128 
129 } // namespace slac
130 } // namespace pipelines
131 } // namespace t
132 } // namespace cloudViewer
cloudViewer
Generic file read and write utility for python interface.
Definition: CloudViewerConfig.cpp:12
PointCloud.h
cloudViewer::t::pipelines::slac::ControlGrid::Parameterize
geometry::PointCloud Parameterize(const geometry::PointCloud &pcd)
Definition: ControlGrid.cpp:150
knncpp::Vector4i
Eigen::Matrix< Index, 4, 1 > Vector4i
Definition: knncpp.h:31
cloudViewer::t::pipelines::slac::ControlGrid::kGrid8NbIndices
static const std::string kGrid8NbIndices
Definition: ControlGrid.h:34
cloudViewer::core::Tensor::GetLength
int64_t GetLength() const
Definition: Tensor.h:1125
cloudViewer::t::geometry::PointCloud::SetPointPositions
void SetPointPositions(const core::Tensor &value)
Set the value of the "positions" attribute. Convenience function.
Definition: PointCloud.h:186
cloudViewer::t::geometry::RGBDImage::depth_
Image depth_
The depth image.
Definition: RGBDImage.h:106
core::Tensor
cloudViewer::t::geometry::PointCloud::GetPointNormals
core::Tensor & GetPointNormals()
Get the value of the "normals" attribute. Convenience function.
Definition: PointCloud.h:130
cloudViewer::t::pipelines::slac::ControlGrid::GetHashMap
std::shared_ptr< core::HashMap > GetHashMap()
Definition: ControlGrid.h:112
ControlGrid.h
cloudViewer::core::Tensor::Contiguous
Tensor Contiguous() const
Definition: Tensor.cpp:772
cloudViewer::t::geometry::PointCloud::GetPointColors
core::Tensor & GetPointColors()
Get the value of the "colors" attribute. Convenience function.
Definition: PointCloud.h:127
cloudViewer::t::pipelines::slac::ControlGrid::kGrid8NbNormalInterpRatios
static const std::string kGrid8NbNormalInterpRatios
8 neighbor grid interpolation ratio for normal per point.
Definition: ControlGrid.h:38
Geometry.h
cloudViewer::t::geometry::Image
The Image class stores image with customizable rows, cols, channels, dtype and device.
Definition: Image.h:29
cloudViewer::core::Tensor::View
Tensor View(const SizeVector &dst_shape) const
Definition: Tensor.cpp:721
cloudViewer::t::geometry::PointCloud::HasPointColors
bool HasPointColors() const
Definition: PointCloud.h:227
cloudViewer::t::geometry::Image::GetRows
int64_t GetRows() const
Get the number of rows of the image.
Definition: Image.h:84
cloudViewer::t::geometry::PointCloud::CreateFromDepthImage
static PointCloud CreateFromDepthImage(const Image &depth, const core::Tensor &intrinsics, const core::Tensor &extrinsics=core::Tensor::Eye(4, core::Float32, core::Device("CPU:0")), float depth_scale=1000.0f, float depth_max=3.0f, int stride=1, bool with_normals=false)
Factory function to create a point cloud from a depth image and a camera model.
Definition: PointCloud.cpp:956
cloudViewer::core::Tensor::GetItem
Tensor GetItem(const TensorKey &tk) const
Definition: Tensor.cpp:473
cloudViewer::t::geometry::PointCloud::ProjectToDepthImage
geometry::Image ProjectToDepthImage(int width, int height, const core::Tensor &intrinsics, const core::Tensor &extrinsics=core::Tensor::Eye(4, core::Float32, core::Device("CPU:0")), float depth_scale=1000.0f, float depth_max=3.0f)
Project a point cloud to a depth image.
Definition: PointCloud.cpp:1013
cloudViewer::t::pipelines::slac::ControlGrid::GetInitPositions
core::Tensor GetInitPositions()
Get control grid original positions directly from tensor keys.
Definition: ControlGrid.h:104
cloudViewer::t::geometry::PointCloud
A point cloud contains a list of 3D points.
Definition: PointCloud.h:82
cloudViewer::t::pipelines::slac::ControlGrid::ControlGrid
ControlGrid()=default
Default constructor.
cloudViewer::t::geometry::PointCloud::HasPointNormals
bool HasPointNormals() const
Definition: PointCloud.h:234
cloudViewer::t::pipelines::slac::ControlGrid
Definition: ControlGrid.h:30
cloudViewer::t::pipelines::slac::ControlGrid::GetCurrPositions
core::Tensor GetCurrPositions()
Definition: ControlGrid.h:110
cloudViewer::core::None
constexpr utility::nullopt_t None
Definition: TensorKey.h:20
cloudViewer::t::pipelines::slac::ControlGrid::Size
int64_t Size()
Definition: ControlGrid.h:113
cloudViewer::t::geometry::PointCloud::ProjectToRGBDImage
geometry::RGBDImage ProjectToRGBDImage(int width, int height, const core::Tensor &intrinsics, const core::Tensor &extrinsics=core::Tensor::Eye(4, core::Float32, core::Device("CPU:0")), float depth_scale=1000.0f, float depth_max=3.0f)
Project a point cloud to an RGBD image.
Definition: PointCloud.cpp:1036
cloudViewer::core::Int32
const Dtype Int32
Definition: Dtype.cpp:46
cloudViewer::core::TensorKey::Index
static TensorKey Index(int64_t index)
Definition: TensorKey.cpp:134
cloudViewer::core::Tensor::T
Tensor T() const
Expects input to be <= 2-D Tensor by swapping dimension 0 and 1.
Definition: Tensor.cpp:1079
cloudViewer::core::Device
Definition: Device.h:18
cloudViewer::t::geometry::kernel::image::To
void To(const core::Tensor &src, core::Tensor &dst, double scale, double offset)
Definition: Image.cpp:17
cloudViewer::t::geometry::PointCloud::SetPointAttr
void SetPointAttr(const std::string &key, const core::Tensor &value)
Definition: PointCloud.h:177
cloudViewer::core::Tensor::IndexGet
Tensor IndexGet(const std::vector< Tensor > &index_tensors) const
Advanced indexing getter. This will always allocate a new Tensor.
Definition: Tensor.cpp:905
cloudViewer::core::HashSet
Definition: HashSet.h:19
cloudViewer::t::pipelines::slac::ControlGrid::Touch
void Touch(const geometry::PointCloud &pcd)
Allocate control grids in the shared camera space.
Definition: ControlGrid.cpp:46
a
a[190]
Definition: essential_matrix_poly.h:19
cloudViewer::t::geometry::Image::GetCols
int64_t GetCols() const
Get the number of columns of the image.
Definition: Image.h:87
cloudViewer::t::pipelines::slac::ControlGrid::kGrid8NbVertexInterpRatios
static const std::string kGrid8NbVertexInterpRatios
8 neighbor grid interpolation ratio for vertex per point.
Definition: ControlGrid.h:36
EigenConverter.h
cloudViewer::core::Float32
const Dtype Float32
Definition: Dtype.cpp:42
cloudViewer::core::SizeVector
Definition: SizeVector.h:70
HashMap.h
HashSet.h
LogError
#define LogError(...)
Definition: Logging.h:60
cloudViewer::t::pipelines::slac::ControlGrid::GetNeighborGridMap
std::tuple< core::Tensor, core::Tensor, core::Tensor > GetNeighborGridMap()
Definition: ControlGrid.cpp:115
cloudViewer::t::geometry::PointCloud::HasPointAttr
bool HasPointAttr(const std::string &key) const
Definition: PointCloud.h:207
cloudViewer::t::geometry::PointCloud::GetPointAttr
const TensorMap & GetPointAttr() const
Getter for point_attr_ TensorMap. Used in Pybind.
Definition: PointCloud.h:111
cloudViewer::core::TensorKey::Slice
static TensorKey Slice(utility::optional< int64_t > start, utility::optional< int64_t > stop, utility::optional< int64_t > step)
Definition: TensorKey.cpp:138
cloudViewer::t::pipelines::slac::ControlGrid::Compactify
void Compactify()
Definition: ControlGrid.cpp:82
Image.h
Tensor.h
cloudViewer::t::geometry::RGBDImage::color_
Image color_
The color image.
Definition: RGBDImage.h:104
cloudViewer::t::geometry::PointCloud::GetPointPositions
core::Tensor & GetPointPositions()
Get the value of the "positions" attribute. Convenience function.
Definition: PointCloud.h:124
cloudViewer::t::pipelines::slac::ControlGrid::Deform
geometry::PointCloud Deform(const geometry::PointCloud &pcd)
Non-rigidly deform a point cloud using the control grid.
Definition: ControlGrid.cpp:241
cloudViewer::t::geometry::PointCloud::CreateFromRGBDImage
static PointCloud CreateFromRGBDImage(const RGBDImage &rgbd_image, const core::Tensor &intrinsics, const core::Tensor &extrinsics=core::Tensor::Eye(4, core::Float32, core::Device("CPU:0")), float depth_scale=1000.0f, float depth_max=3.0f, int stride=1, bool with_normals=false)
Factory function to create a point cloud from an RGB-D image and a camera model.
Definition: PointCloud.cpp:986
cloudViewer::core::eigen_converter::TensorToEigenVector3iVector
std::vector< Eigen::Vector3i > TensorToEigenVector3iVector(const core::Tensor &tensor)
Converts a tensor of shape (N, 3) to std::vector<Eigen::Vector3i>. An exception will be thrown if the...
Definition: EigenConverter.cpp:155
cloudViewer::t::geometry::PointCloud::SetPointNormals
void SetPointNormals(const core::Tensor &value)
Set the value of the "normals" attribute. Convenience function.
Definition: PointCloud.h:198
cloudViewer::t::pipelines::slac::ControlGrid::GetDevice
core::Device GetDevice()
Definition: ControlGrid.h:115
cloudViewer::core::Int64
const Dtype Int64
Definition: Dtype.cpp:47
cloudViewer::core::Tensor::To
Tensor To(Dtype dtype, bool copy=false) const
Definition: Tensor.cpp:739
cloudViewer::t::geometry::RGBDImage
RGBDImage A pair of color and depth images.
Definition: RGBDImage.h:21
cloudViewer::t::pipelines::slac::ControlGrid::GetAnchorIdx
int64_t GetAnchorIdx()
Definition: ControlGrid.h:116
cloudViewer::t::geometry::PointCloud::SetPointColors
void SetPointColors(const core::Tensor &value)
Set the value of the "colors" attribute. Convenience function.
Definition: PointCloud.h:192
cloudViewer::core::Tensor::Floor
Tensor Floor() const
Element-wise floor value of a tensor, returning a new tensor.
Definition: Tensor.cpp:1411