Open3D (C++ API)  0.15.1
RealSenseSensor.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 <string>
30
35
36namespace rs2 {
37class pipeline;
38class align;
39class config;
40} // namespace rs2
41
42namespace open3d {
43namespace t {
44namespace io {
45
48public:
52 static std::vector<RealSenseValidConfigs> EnumerateDevices();
56 static bool ListDevices();
57
62 virtual ~RealSenseSensor() override;
63
79 virtual bool InitSensor(const RealSenseSensorConfig &sensor_config =
81 size_t sensor_index = 0,
82 const std::string &filename = "");
83 virtual bool InitSensor(const RGBDSensorConfig &sensor_config,
84 size_t sensor_index = 0,
85 const std::string &filename = "") override {
86 return InitSensor(
87 dynamic_cast<const RealSenseSensorConfig &>(sensor_config),
88 sensor_index, filename);
89 }
90
93 virtual bool StartCapture(bool start_record = false) override;
94
99 virtual void PauseRecord() override;
100
103 virtual void ResumeRecord() override;
104
112 bool wait = true, bool align_depth_to_color = true) override;
113
119 virtual uint64_t GetTimestamp() const override { return timestamp_; }
120
122 virtual void StopCapture() override;
123
125 virtual const RGBDVideoMetadata &GetMetadata() const override {
126 return metadata_;
127 }
128
130 virtual std::string GetFilename() const override { return filename_; };
131
134
135private:
136 bool enable_recording_ = false;
137 bool is_recording_ = false;
138 bool is_capturing_ = false;
139 std::string filename_;
140 geometry::RGBDImage current_frame_;
141 uint64_t timestamp_ = 0;
142 RGBDVideoMetadata metadata_;
143 std::unique_ptr<rs2::pipeline> pipe_;
144 std::unique_ptr<rs2::align> align_to_color_;
145 std::unique_ptr<rs2::config> rs_config_;
146
147 static const uint64_t MILLISEC_TO_MICROSEC = 1000;
148};
149
150} // namespace io
151} // namespace t
152} // namespace open3d
Definition: RGBDSensorConfig.h:34
RGBDImage A pair of color and depth images.
Definition: RGBDImage.h:40
Interface class for control of RGBD cameras.
Definition: RGBDSensor.h:41
virtual const std::string ToString() const
Text Description.
Definition: RGBDSensor.h:100
RGBD video metadata.
Definition: RGBDVideoMetadata.h:45
Definition: RealSenseSensorConfig.h:81
RealSense camera discovery, configuration, streaming and recording.
Definition: RealSenseSensor.h:47
virtual void StopCapture() override
Stop capturing frames.
Definition: RealSenseSensor.cpp:307
virtual void PauseRecord() override
Definition: RealSenseSensor.cpp:246
virtual void ResumeRecord() override
Definition: RealSenseSensor.cpp:253
RealSenseSensor()
Default constructor. Initialize with default settings.
Definition: RealSenseSensor.cpp:134
RealSenseSensor & operator=(const RealSenseSensor &)=delete
virtual geometry::RGBDImage CaptureFrame(bool wait=true, bool align_depth_to_color=true) override
Definition: RealSenseSensor.cpp:274
virtual ~RealSenseSensor() override
Definition: RealSenseSensor.cpp:141
RealSenseSensor(const RealSenseSensor &)=delete
static std::vector< RealSenseValidConfigs > EnumerateDevices()
Definition: RealSenseSensor.cpp:64
virtual const RGBDVideoMetadata & GetMetadata() const override
Get metadata of the RealSense video capture.
Definition: RealSenseSensor.h:125
static bool ListDevices()
Definition: RealSenseSensor.cpp:43
virtual bool StartCapture(bool start_record=false) override
Definition: RealSenseSensor.cpp:216
virtual bool InitSensor(const RGBDSensorConfig &sensor_config, size_t sensor_index=0, const std::string &filename="") override
Definition: RealSenseSensor.h:83
virtual uint64_t GetTimestamp() const override
Definition: RealSenseSensor.h:119
virtual std::string GetFilename() const override
Get filename being written.
Definition: RealSenseSensor.h:130
virtual bool InitSensor(const RealSenseSensorConfig &sensor_config=RealSenseSensorConfig{}, size_t sensor_index=0, const std::string &filename="")
Definition: RealSenseSensor.cpp:143
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample uint64_t
Definition: K4aPlugin.cpp:362
Definition: PinholeCameraIntrinsic.cpp:35
Definition: RealSenseSensor.h:36