Open3D (C++ API)  0.15.1
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
32namespace open3d {
33namespace t {
34namespace geometry {
35
40class RGBDImage : public Geometry {
41public:
50 RGBDImage(const Image &color, const Image &depth, bool aligned = true)
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
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
109public:
115 bool aligned_ = true;
116};
117
118} // namespace geometry
119} // namespace t
120} // namespace open3d
math::float4 color
Definition: LineSetBuffers.cpp:64
#define LogWarning(...)
Definition: Logging.h:79
Definition: Device.h:39
Definition: Tensor.h:51
static Tensor Zeros(const SizeVector &shape, Dtype dtype, const Device &device=Device("CPU:0"))
Create a tensor fill with zeros.
Definition: Tensor.cpp:380
RGBDImage is for a pair of registered color and depth images,.
Definition: RGBDImage.h:46
The base geometry class.
Definition: Geometry.h:38
GeometryType
Specifies possible geometry types.
Definition: Geometry.h:43
The Image class stores image with customizable rows, cols, channels, dtype and device.
Definition: Image.h:48
int64_t GetRows() const
Get the number of rows of the image.
Definition: Image.h:103
core::Device GetDevice() const
Get device of the image.
Definition: Image.h:115
int64_t GetCols() const
Get the number of columns of the image.
Definition: Image.h:106
open3d::geometry::Image ToLegacy() const
Convert to legacy Image type.
Definition: Image.cpp:553
Image To(const core::Device &device, bool copy=false) const
Transfer the image to a specified device.
Definition: Image.h:151
RGBDImage A pair of color and depth images.
Definition: RGBDImage.h:40
Image color_
The color image.
Definition: RGBDImage.h:111
std::string ToString() const
Text description.
Definition: RGBDImage.cpp:41
Image depth_
The depth image.
Definition: RGBDImage.h:113
RGBDImage()
Default Comnstructor.
Definition: RGBDImage.h:43
RGBDImage Clone() const
Returns copy of the RGBD image on the same device.
Definition: RGBDImage.h:98
core::Tensor GetMaxBound() const
Compute max 2D coordinates for the data.
Definition: RGBDImage.h:80
RGBDImage & Clear() override
Clear stored data.
Definition: RGBDImage.cpp:33
~RGBDImage() override
Definition: RGBDImage.h:63
bool AreAligned() const
Are the depth and color images aligned (same viewpoint and resolution)?
Definition: RGBDImage.h:72
open3d::geometry::RGBDImage ToLegacy() const
Convert to the legacy RGBDImage format.
Definition: RGBDImage.h:101
RGBDImage(const Image &color, const Image &depth, bool aligned=true)
Parameterized Constructor.
Definition: RGBDImage.h:50
RGBDImage To(const core::Device &device, bool copy=false) const
Definition: RGBDImage.h:92
bool aligned_
Are the depth and color images aligned (same viewpoint and resolution)?
Definition: RGBDImage.h:115
core::Tensor GetMinBound() const
Compute min 2D coordinates for the data (always {0,0}).
Definition: RGBDImage.h:75
bool IsEmpty() const override
Is any data stored?
Definition: RGBDImage.cpp:39
const Dtype Int64
Definition: Dtype.cpp:66
Definition: PinholeCameraIntrinsic.cpp:35