Loading [MathJax]/extensions/TeX/AMSsymbols.js
Open3D (C++ API)  0.14.1
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:
50  RGBDImage(const Image &color, const Image &depth, bool aligned = true)
52  color_(color),
53  depth_(depth),
54  aligned_(aligned) {
55  if (color.GetRows() != depth.GetRows() ||
56  color.GetCols() != depth.GetCols()) {
57  aligned_ = false;
59  "Aligned image pair must have the same resolution.");
60  }
61  }
62 
63  ~RGBDImage() override{};
64 
66  RGBDImage &Clear() override;
67 
69  bool IsEmpty() const override;
70 
72  bool AreAligned() const { return aligned_; }
73 
76  return core::Tensor::Zeros({2}, core::Int64);
77  };
78 
81  return core::Tensor(
82  std::vector<int64_t>{color_.GetCols() + depth_.GetCols(),
83  color_.GetRows()},
84  {2}, core::Int64);
85  };
86 
92  RGBDImage To(const core::Device &device, bool copy = false) const {
93  return RGBDImage(color_.To(device, copy), depth_.To(device, copy),
94  aligned_);
95  }
96 
98  RGBDImage Clone() const { return To(color_.GetDevice(), /*copy=*/true); }
99 
103  depth_.ToLegacy());
104  }
105 
107  std::string ToString() const;
108 
109 public:
115  bool aligned_ = true;
116 };
117 
118 } // namespace geometry
119 } // namespace t
120 } // namespace open3d
RGBDImage()
Default Comnstructor.
Definition: RGBDImage.h:43
RGBDImage To(const core::Device &device, bool copy=false) const
Definition: RGBDImage.h:92
bool AreAligned() const
Are the depth and color images aligned (same viewpoint and resolution)?
Definition: RGBDImage.h:72
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:43
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:80
open3d::geometry::Image ToLegacy() const
Convert to legacy Image type.
Definition: Image.cpp:583
#define LogWarning(...)
Definition: Logging.h:84
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:75
bool aligned_
Are the depth and color images aligned (same viewpoint and resolution)?
Definition: RGBDImage.h:115
core::Device GetDevice() const
Get device of the image.
Definition: Image.h:115
Definition: Device.h:39
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
RGBDImage(const Image &color, const Image &depth, bool aligned=true)
Parameterized Constructor.
Definition: RGBDImage.h:50
std::string ToString() const
Text description.
Definition: RGBDImage.cpp:41
open3d::geometry::RGBDImage ToLegacy() const
Convert to the legacy RGBDImage format.
Definition: RGBDImage.h:101
static Tensor Zeros(const SizeVector &shape, Dtype dtype, const Device &device=Device("CPU:0"))
Create a tensor fill with zeros.
Definition: Tensor.cpp:380
The base geometry class.
Definition: Geometry.h:38
RGBDImage Clone() const
Returns copy of the RGBD image on the same device.
Definition: RGBDImage.h:98
Definition: PinholeCameraIntrinsic.cpp:35
RGBDImage A pair of color and depth images.
Definition: RGBDImage.h:40
Image color_
The color image.
Definition: RGBDImage.h:111
Image To(const core::Device &device, bool copy=false) const
Transfer the image to a specified device.
Definition: Image.h:151
~RGBDImage() override
Definition: RGBDImage.h:63
RGBDImage & Clear() override
Clear stored data.
Definition: RGBDImage.cpp:33
Image depth_
The depth image.
Definition: RGBDImage.h:113