Loading [MathJax]/extensions/TeX/AMSsymbols.js
Open3D (C++ API)  0.14.1
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"
33 
34 namespace open3d {
35 namespace t {
36 namespace pipelines {
37 namespace slam {
38 
41 class Frame {
42 public:
44  int width,
45  const core::Tensor& intrinsics,
46  const core::Device& device)
47  : height_(height),
48  width_(width),
49  intrinsics_(intrinsics),
50  device_(device) {}
51 
52  int GetHeight() const { return height_; }
53  int GetWidth() const { return width_; }
54 
55  void SetIntrinsics(const core::Tensor& intrinsics) {
56  intrinsics_ = intrinsics;
57  }
58  core::Tensor GetIntrinsics() const { return intrinsics_; }
59 
60  void SetData(const std::string& name, const core::Tensor& data) {
61  data_[name] = data.To(device_);
62  }
63  core::Tensor GetData(const std::string& name) const {
64  if (data_.count(name) == 0) {
66  "Property not found for {}, return an empty tensor!", name);
67  return core::Tensor();
68  }
69  return data_.at(name);
70  }
71 
72  // Convenient interface for images
73  void SetDataFromImage(const std::string& name,
74  const t::geometry::Image& data) {
75  SetData(name, data.AsTensor());
76  }
77 
78  t::geometry::Image GetDataAsImage(const std::string& name) const {
79  return t::geometry::Image(GetData(name));
80  }
81 
82 private:
83  int height_;
84  int width_;
85 
86  // (3, 3) intrinsic matrix for a pinhole camera
87  core::Tensor intrinsics_;
88  core::Device device_;
89 
90  // Maintained maps, including:
91  // depth_map: (H, W, 1), Float32 AFTER preprocessing
92  // vertex_map: (H, W, 3), Float32,
93  // color_map: (H, W, 3), Float32
94  // normal_map: (H, W, 3), Float32
95  std::unordered_map<std::string, core::Tensor> data_;
96 };
97 
98 } // namespace slam
99 } // namespace pipelines
100 } // namespace t
101 } // namespace open3d
core::Tensor GetData(const std::string &name) const
Definition: Frame.h:63
int height
Definition: FilePCD.cpp:72
t::geometry::Image GetDataAsImage(const std::string &name) const
Definition: Frame.h:78
int GetHeight() const
Definition: Frame.h:52
int GetWidth() const
Definition: Frame.h:53
Frame(int height, int width, const core::Tensor &intrinsics, const core::Device &device)
Definition: Frame.h:43
#define LogWarning(...)
Definition: Logging.h:84
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:60
Tensor To(Dtype dtype, bool copy=false) const
Definition: Tensor.cpp:713
Definition: Device.h:39
void SetIntrinsics(const core::Tensor &intrinsics)
Definition: Frame.h:55
core::Tensor GetIntrinsics() const
Definition: Frame.h:58
Definition: PinholeCameraIntrinsic.cpp:35
void SetDataFromImage(const std::string &name, const t::geometry::Image &data)
Definition: Frame.h:73
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:41
const char const char value recording_handle imu_sample recording_handle uint8_t data
Definition: K4aPlugin.cpp:274