Loading [MathJax]/extensions/TeX/AMSsymbols.js
Open3D (C++ API)  0.16.0
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
RGBDImage.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 
31 
32 namespace open3d {
33 namespace t {
34 namespace geometry {
35 
40 class RGBDImage : public Geometry {
41 public:
44 
51  RGBDImage(const Image &color, const Image &depth, bool aligned = true)
53  color_(color),
54  depth_(depth),
55  aligned_(aligned) {
56  if (color.GetRows() != depth.GetRows() ||
57  color.GetCols() != depth.GetCols()) {
58  aligned_ = false;
60  "Aligned image pair must have the same resolution.");
61  }
62  }
63 
64  core::Device GetDevice() const override {
65  core::Device color_device = color_.GetDevice();
66  core::Device depth_device = depth_.GetDevice();
67  if (color_device != depth_device) {
69  "Color {} and depth {} are not on the same device.",
70  color_device.ToString(), depth_device.ToString());
71  }
72  return color_device;
73  }
74 
75  ~RGBDImage() override{};
76 
78  RGBDImage &Clear() override;
79 
81  bool IsEmpty() const override;
82 
84  bool AreAligned() const { return aligned_; }
85 
88  return core::Tensor::Zeros({2}, core::Int64);
89  }
90 
93  return core::Tensor(
94  std::vector<int64_t>{color_.GetCols() + depth_.GetCols(),
95  color_.GetRows()},
96  {2}, core::Int64);
97  }
98 
104  RGBDImage To(const core::Device &device, bool copy = false) const {
105  return RGBDImage(color_.To(device, copy), depth_.To(device, copy),
106  aligned_);
107  }
108 
110  RGBDImage Clone() const { return To(color_.GetDevice(), /*copy=*/true); }
111 
115  depth_.ToLegacy());
116  }
117 
119  std::string ToString() const;
120 
121 public:
127  bool aligned_ = true;
128 };
129 
130 } // namespace geometry
131 } // namespace t
132 } // namespace open3d
RGBDImage()
Default Comnstructor.
Definition: RGBDImage.h:43
RGBDImage To(const core::Device &device, bool copy=false) const
Definition: RGBDImage.h:104
bool AreAligned() const
Are the depth and color images aligned (same viewpoint and resolution)?
Definition: RGBDImage.h:84
const Dtype Int64
Definition: Dtype.cpp:66
int64_t GetRows() const
Get the number of rows of the image.
Definition: Image.h:103
GeometryType
Specifies possible geometry types.
Definition: Geometry.h:45
bool IsEmpty() const override
Is any data stored?
Definition: RGBDImage.cpp:39
core::Tensor GetMaxBound() const
Compute max 2D coordinates for the data.
Definition: RGBDImage.h:92
open3d::geometry::Image ToLegacy() const
Convert to legacy Image type.
Definition: Image.cpp:546
#define LogWarning(...)
Definition: Logging.h:79
The Image class stores image with customizable rows, cols, channels, dtype and device.
Definition: Image.h:48
math::float4 color
Definition: LineSetBuffers.cpp:64
core::Tensor GetMinBound() const
Compute min 2D coordinates for the data (always {0,0}).
Definition: RGBDImage.h:87
bool aligned_
Are the depth and color images aligned (same viewpoint and resolution)?
Definition: RGBDImage.h:127
Definition: Device.h:37
int64_t GetCols() const
Get the number of columns of the image.
Definition: Image.h:106
RGBDImage is for a pair of registered color and depth images,.
Definition: RGBDImage.h:46
core::Device GetDevice() const override
Returns the device of the geometry.
Definition: RGBDImage.h:64
RGBDImage(const Image &color, const Image &depth, bool aligned=true)
Parameterized Constructor.
Definition: RGBDImage.h:51
std::string ToString() const
Text description.
Definition: RGBDImage.cpp:41
open3d::geometry::RGBDImage ToLegacy() const
Convert to the legacy RGBDImage format.
Definition: RGBDImage.h:113
static Tensor Zeros(const SizeVector &shape, Dtype dtype, const Device &device=Device("CPU:0"))
Create a tensor fill with zeros.
Definition: Tensor.cpp:392
The base geometry class.
Definition: Geometry.h:40
RGBDImage Clone() const
Returns copy of the RGBD image on the same device.
Definition: RGBDImage.h:110
Definition: PinholeCameraIntrinsic.cpp:35
RGBDImage A pair of color and depth images.
Definition: RGBDImage.h:40
Image color_
The color image.
Definition: RGBDImage.h:123
core::Device GetDevice() const override
Get device of the image.
Definition: Image.h:115
Image To(const core::Device &device, bool copy=false) const
Transfer the image to a specified device.
Definition: Image.h:151
bool copy
Definition: VtkUtils.cpp:89
std::string ToString() const
Returns string representation of device, e.g. "CPU:0", "CUDA:0".
Definition: Device.cpp:107
#define LogError(...)
Definition: Logging.h:67
~RGBDImage() override
Definition: RGBDImage.h:75
RGBDImage & Clear() override
Clear stored data.
Definition: RGBDImage.cpp:33
Image depth_
The depth image.
Definition: RGBDImage.h:125