Loading [MathJax]/extensions/TeX/AMSsymbols.js
Open3D (C++ API)  0.16.0
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Frame.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"
32 
33 namespace open3d {
34 namespace t {
35 namespace pipelines {
36 namespace slam {
37 
40 class Frame {
41 public:
43  int width,
44  const core::Tensor& intrinsics,
45  const core::Device& device)
46  : height_(height),
47  width_(width),
48  intrinsics_(intrinsics),
49  device_(device) {}
50 
51  int GetHeight() const { return height_; }
52  int GetWidth() const { return width_; }
53 
54  void SetIntrinsics(const core::Tensor& intrinsics) {
55  intrinsics_ = intrinsics;
56  }
57  core::Tensor GetIntrinsics() const { return intrinsics_; }
58 
59  void SetData(const std::string& name, const core::Tensor& data) {
60  data_[name] = data.To(device_);
61  }
62  core::Tensor GetData(const std::string& name) const {
63  if (data_.count(name) == 0) {
65  "Property not found for {}, return an empty tensor!", name);
66  return core::Tensor();
67  }
68  return data_.at(name);
69  }
70 
71  // Convenient interface for images
72  void SetDataFromImage(const std::string& name,
73  const t::geometry::Image& data) {
74  SetData(name, data.AsTensor());
75  }
76 
77  t::geometry::Image GetDataAsImage(const std::string& name) const {
78  return t::geometry::Image(GetData(name));
79  }
80 
81 private:
82  int height_;
83  int width_;
84 
85  // (3, 3) intrinsic matrix for a pinhole camera
86  core::Tensor intrinsics_;
87  core::Device device_;
88 
89  // Maintained maps, including:
90  // depth_map: (H, W, 1), Float32 AFTER preprocessing
91  // vertex_map: (H, W, 3), Float32,
92  // color_map: (H, W, 3), Float32
93  // normal_map: (H, W, 3), Float32
94  std::unordered_map<std::string, core::Tensor> data_;
95 };
96 
97 } // namespace slam
98 } // namespace pipelines
99 } // namespace t
100 } // namespace open3d
core::Tensor GetData(const std::string &name) const
Definition: Frame.h:62
int height
Definition: FilePCD.cpp:72
t::geometry::Image GetDataAsImage(const std::string &name) const
Definition: Frame.h:77
int GetHeight() const
Definition: Frame.h:51
int GetWidth() const
Definition: Frame.h:52
Frame(int height, int width, const core::Tensor &intrinsics, const core::Device &device)
Definition: Frame.h:42
#define LogWarning(...)
Definition: Logging.h:79
The Image class stores image with customizable rows, cols, channels, dtype and device.
Definition: Image.h:48
void SetData(const std::string &name, const core::Tensor &data)
Definition: Frame.h:59
Tensor To(Dtype dtype, bool copy=false) const
Definition: Tensor.cpp:725
Definition: Device.h:37
void SetIntrinsics(const core::Tensor &intrinsics)
Definition: Frame.h:54
core::Tensor GetIntrinsics() const
Definition: Frame.h:57
Definition: PinholeCameraIntrinsic.cpp:35
void SetDataFromImage(const std::string &name, const t::geometry::Image &data)
Definition: Frame.h:72
int width
Definition: FilePCD.cpp:71
core::Tensor AsTensor() const
Returns the underlying Tensor of the Image.
Definition: Image.h:143
std::string name
Definition: FilePCD.cpp:58
Frame is a container class storing an intrinsic matrix and several 2D tensors, from depth map...
Definition: Frame.h:40
const char const char value recording_handle imu_sample recording_handle uint8_t data
Definition: K4aPlugin.cpp:284