Open3D (C++ API)  0.16.0
ControlGrid.h
Go to the documentation of this file.
1// ----------------------------------------------------------------------------
2// - Open3D: www.open3d.org -
3// ----------------------------------------------------------------------------
4// The MIT License (MIT)
5//
6// Copyright (c) 2018-2021 www.open3d.org
7//
8// Permission is hereby granted, free of charge, to any person obtaining a copy
9// of this software and associated documentation files (the "Software"), to deal
10// in the Software without restriction, including without limitation the rights
11// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12// copies of the Software, and to permit persons to whom the Software is
13// furnished to do so, subject to the following conditions:
14//
15// The above copyright notice and this permission notice shall be included in
16// all copies or substantial portions of the Software.
17//
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24// IN THE SOFTWARE.
25// ----------------------------------------------------------------------------
26
27#pragma once
28
29#include "open3d/core/Tensor.h"
34
35namespace open3d {
36namespace t {
37namespace pipelines {
38namespace slac {
39
50public:
53 static const std::string kGrid8NbIndices;
55 static const std::string kGrid8NbVertexInterpRatios;
57 static const std::string kGrid8NbNormalInterpRatios;
58
60 ControlGrid() = default;
61
63 ControlGrid(float grid_size,
64 int64_t grid_count = 1000,
65 const core::Device& device = core::Device("CPU:0"));
66
69 ControlGrid(float grid_size,
70 const core::Tensor& keys,
71 const core::Tensor& values,
72 const core::Device& device = core::Device("CPU:0"));
73
75 void Touch(const geometry::PointCloud& pcd);
76
79 void Compactify();
80
88 std::tuple<core::Tensor, core::Tensor, core::Tensor> GetNeighborGridMap();
89
98
101
107 const core::Tensor& intrinsics,
108 const core::Tensor& extrinsics,
109 float depth_scale,
110 float depth_max);
111
117 const core::Tensor& intrinsics,
118 const core::Tensor& extrinsics,
119 float depth_scale,
120 float depth_max);
121
124 return ctr_hashmap_->GetKeyTensor().To(core::Float32) * grid_size_;
125 }
126
129 core::Tensor GetCurrPositions() { return ctr_hashmap_->GetValueTensor(); }
130
131 std::shared_ptr<core::HashMap> GetHashMap() { return ctr_hashmap_; }
132 int64_t Size() { return ctr_hashmap_->Size(); }
133
134 core::Device GetDevice() { return device_; }
135 int64_t GetAnchorIdx() { return anchor_idx_; }
136
137private:
139 int64_t anchor_idx_ = 0;
140
142 float grid_size_;
143
144 core::Device device_ = core::Device("CPU:0");
145 std::shared_ptr<core::HashMap> ctr_hashmap_;
146};
147
148} // namespace slac
149} // namespace pipelines
150} // namespace t
151} // namespace open3d
Definition: Device.h:37
Definition: Tensor.h:51
The Image class stores image with customizable rows, cols, channels, dtype and device.
Definition: Image.h:48
A point cloud contains a list of 3D points.
Definition: PointCloud.h:99
RGBDImage A pair of color and depth images.
Definition: RGBDImage.h:40
Definition: ControlGrid.h:49
int64_t GetAnchorIdx()
Definition: ControlGrid.h:135
static const std::string kGrid8NbIndices
Definition: ControlGrid.h:53
geometry::PointCloud Deform(const geometry::PointCloud &pcd)
Non-rigidly deform a point cloud using the control grid.
Definition: ControlGrid.cpp:260
static const std::string kGrid8NbVertexInterpRatios
8 neighbor grid interpolation ratio for vertex per point.
Definition: ControlGrid.h:55
void Touch(const geometry::PointCloud &pcd)
Allocate control grids in the shared camera space.
Definition: ControlGrid.cpp:65
ControlGrid()=default
Default constructor.
core::Tensor GetInitPositions()
Get control grid original positions directly from tensor keys.
Definition: ControlGrid.h:123
core::Tensor GetCurrPositions()
Definition: ControlGrid.h:129
core::Device GetDevice()
Definition: ControlGrid.h:134
int64_t Size()
Definition: ControlGrid.h:132
static const std::string kGrid8NbNormalInterpRatios
8 neighbor grid interpolation ratio for normal per point.
Definition: ControlGrid.h:57
std::tuple< core::Tensor, core::Tensor, core::Tensor > GetNeighborGridMap()
Definition: ControlGrid.cpp:134
geometry::PointCloud Parameterize(const geometry::PointCloud &pcd)
Definition: ControlGrid.cpp:169
std::shared_ptr< core::HashMap > GetHashMap()
Definition: ControlGrid.h:131
void Compactify()
Definition: ControlGrid.cpp:101
const Dtype Float32
Definition: Dtype.cpp:61
Definition: PinholeCameraIntrinsic.cpp:35