Open3D (C++ API)  0.18.0+252c867
ControlGrid.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2023 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include "open3d/core/Tensor.h"
15 
16 namespace open3d {
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 open3d
Definition: Device.h:18
Definition: Tensor.h:32
The Image class stores image with customizable rows, cols, channels, dtype and device.
Definition: Image.h:29
A point cloud contains a list of 3D points.
Definition: PointCloud.h:80
RGBDImage A pair of color and depth images.
Definition: RGBDImage.h:21
Definition: ControlGrid.h:30
int64_t GetAnchorIdx()
Definition: ControlGrid.h:116
static const std::string kGrid8NbIndices
Definition: ControlGrid.h:34
geometry::PointCloud Deform(const geometry::PointCloud &pcd)
Non-rigidly deform a point cloud using the control grid.
Definition: ControlGrid.cpp:241
static const std::string kGrid8NbVertexInterpRatios
8 neighbor grid interpolation ratio for vertex per point.
Definition: ControlGrid.h:36
void Touch(const geometry::PointCloud &pcd)
Allocate control grids in the shared camera space.
Definition: ControlGrid.cpp:46
ControlGrid()=default
Default constructor.
std::shared_ptr< core::HashMap > GetHashMap()
Definition: ControlGrid.h:112
core::Tensor GetInitPositions()
Get control grid original positions directly from tensor keys.
Definition: ControlGrid.h:104
core::Tensor GetCurrPositions()
Definition: ControlGrid.h:110
core::Device GetDevice()
Definition: ControlGrid.h:115
int64_t Size()
Definition: ControlGrid.h:113
static const std::string kGrid8NbNormalInterpRatios
8 neighbor grid interpolation ratio for normal per point.
Definition: ControlGrid.h:38
std::tuple< core::Tensor, core::Tensor, core::Tensor > GetNeighborGridMap()
Definition: ControlGrid.cpp:115
geometry::PointCloud Parameterize(const geometry::PointCloud &pcd)
Definition: ControlGrid.cpp:150
void Compactify()
Definition: ControlGrid.cpp:82
const Dtype Float32
Definition: Dtype.cpp:42
Definition: PinholeCameraIntrinsic.cpp:16