Open3D (C++ API)  0.18.0+5c982c7
RGBDImage.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2023 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
12 
13 namespace open3d {
14 namespace t {
15 namespace geometry {
16 
21 class RGBDImage : public Geometry {
22 public:
25 
32  RGBDImage(const Image &color, const Image &depth, bool aligned = true)
34  color_(color),
35  depth_(depth),
36  aligned_(aligned) {
37  if (color.GetRows() != depth.GetRows() ||
38  color.GetCols() != depth.GetCols()) {
39  aligned_ = false;
41  "Aligned image pair must have the same resolution.");
42  }
43  }
44 
45  core::Device GetDevice() const override {
46  core::Device color_device = color_.GetDevice();
47  core::Device depth_device = depth_.GetDevice();
48  if (color_device != depth_device) {
50  "Color {} and depth {} are not on the same device.",
51  color_device.ToString(), depth_device.ToString());
52  }
53  return color_device;
54  }
55 
56  ~RGBDImage() override{};
57 
59  RGBDImage &Clear() override;
60 
62  bool IsEmpty() const override;
63 
65  bool AreAligned() const { return aligned_; }
66 
69  return core::Tensor::Zeros({2}, core::Int64);
70  }
71 
74  return core::Tensor(
75  std::vector<int64_t>{color_.GetCols() + depth_.GetCols(),
76  color_.GetRows()},
77  {2}, core::Int64);
78  }
79 
85  RGBDImage To(const core::Device &device, bool copy = false) const {
86  return RGBDImage(color_.To(device, copy), depth_.To(device, copy),
87  aligned_);
88  }
89 
91  RGBDImage Clone() const { return To(color_.GetDevice(), /*copy=*/true); }
92 
96  depth_.ToLegacy());
97  }
98 
100  std::string ToString() const;
101 
102 public:
108  bool aligned_ = true;
109 };
110 
111 } // namespace geometry
112 } // namespace t
113 } // namespace open3d
math::float4 color
Definition: LineSetBuffers.cpp:45
#define LogWarning(...)
Definition: Logging.h:60
#define LogError(...)
Definition: Logging.h:48
bool copy
Definition: VtkUtils.cpp:73
Definition: Device.h:18
std::string ToString() const
Returns string representation of device, e.g. "CPU:0", "CUDA:0".
Definition: Device.cpp:88
Definition: Tensor.h:32
static Tensor Zeros(const SizeVector &shape, Dtype dtype, const Device &device=Device("CPU:0"))
Create a tensor fill with zeros.
Definition: Tensor.cpp:374
RGBDImage is for a pair of registered color and depth images,.
Definition: RGBDImage.h:27
The base geometry class.
Definition: Geometry.h:21
GeometryType
Specifies possible geometry types.
Definition: Geometry.h:26
The Image class stores image with customizable rows, cols, channels, dtype and device.
Definition: Image.h:29
core::Device GetDevice() const override
Get device of the image.
Definition: Image.h:96
int64_t GetRows() const
Get the number of rows of the image.
Definition: Image.h:84
int64_t GetCols() const
Get the number of columns of the image.
Definition: Image.h:87
open3d::geometry::Image ToLegacy() const
Convert to legacy Image type.
Definition: Image.cpp:527
Image To(const core::Device &device, bool copy=false) const
Transfer the image to a specified device.
Definition: Image.h:132
RGBDImage A pair of color and depth images.
Definition: RGBDImage.h:21
Image color_
The color image.
Definition: RGBDImage.h:104
std::string ToString() const
Text description.
Definition: RGBDImage.cpp:22
Image depth_
The depth image.
Definition: RGBDImage.h:106
RGBDImage()
Default Comnstructor.
Definition: RGBDImage.h:24
RGBDImage Clone() const
Returns copy of the RGBD image on the same device.
Definition: RGBDImage.h:91
core::Tensor GetMaxBound() const
Compute max 2D coordinates for the data.
Definition: RGBDImage.h:73
RGBDImage & Clear() override
Clear stored data.
Definition: RGBDImage.cpp:14
~RGBDImage() override
Definition: RGBDImage.h:56
bool AreAligned() const
Are the depth and color images aligned (same viewpoint and resolution)?
Definition: RGBDImage.h:65
open3d::geometry::RGBDImage ToLegacy() const
Convert to the legacy RGBDImage format.
Definition: RGBDImage.h:94
RGBDImage(const Image &color, const Image &depth, bool aligned=true)
Parameterized Constructor.
Definition: RGBDImage.h:32
RGBDImage To(const core::Device &device, bool copy=false) const
Definition: RGBDImage.h:85
bool aligned_
Are the depth and color images aligned (same viewpoint and resolution)?
Definition: RGBDImage.h:108
core::Tensor GetMinBound() const
Compute min 2D coordinates for the data (always {0,0}).
Definition: RGBDImage.h:68
bool IsEmpty() const override
Is any data stored?
Definition: RGBDImage.cpp:20
core::Device GetDevice() const override
Returns the device of the geometry.
Definition: RGBDImage.h:45
const Dtype Int64
Definition: Dtype.cpp:47
Definition: PinholeCameraIntrinsic.cpp:16