Open3D (C++ API)  0.12.0
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 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 
36 namespace rs2 {
37 class pipeline;
38 class align;
39 class config;
40 } // namespace rs2
41 
42 namespace open3d {
43 namespace t {
44 namespace io {
45 
47 class RealSenseSensor : public RGBDSensor {
48 public:
52  static std::vector<RealSenseValidConfigs> EnumerateDevices();
56  static bool ListDevices();
57 
60  RealSenseSensor(const RealSenseSensor &) = delete;
61  RealSenseSensor &operator=(const RealSenseSensor &) = delete;
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 
96  virtual void PauseRecord() override;
97 
100  virtual void ResumeRecord() override;
101 
108  virtual geometry::RGBDImage CaptureFrame(
109  bool wait = true, bool align_depth_to_color = true) override;
110 
116  virtual uint64_t GetTimestamp() const override { return timestamp_; }
117 
119  virtual void StopCapture() override;
120 
122  virtual const RGBDVideoMetadata &GetMetadata() const override {
123  return metadata_;
124  }
125 
127  virtual std::string GetFilename() const override { return filename_; };
128 
130  using RGBDSensor::ToString;
131 
132 private:
133  bool enable_recording_ = false;
134  bool is_recording_ = false;
135  bool is_capturing_ = false;
136  std::string filename_;
137  geometry::RGBDImage current_frame_;
138  uint64_t timestamp_ = 0;
139  RGBDVideoMetadata metadata_;
140  std::unique_ptr<rs2::pipeline> pipe_;
141  std::unique_ptr<rs2::align> align_to_color_;
142  std::unique_ptr<rs2::config> rs_config_;
143 
144  static const uint64_t MILLISEC_TO_MICROSEC = 1000;
145 };
146 
147 } // namespace io
148 } // namespace t
149 } // namespace open3d
RealSense camera discovery, configuration, streaming and recording.
Definition: RealSenseSensor.h:47
Definition: RealSenseSensor.h:36
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:352
Interface class for control of RGBD cameras.
Definition: RGBDSensor.h:41
RGBD video metadata.
Definition: RGBDVideoMetadata.h:45
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:116
Definition: RealSenseSensorConfig.h:81
Definition: PinholeCameraIntrinsic.cpp:35
RGBDImage A pair of color and depth images.
Definition: RGBDImage.h:40
virtual const RGBDVideoMetadata & GetMetadata() const override
Get metadata of the RealSense video capture.
Definition: RealSenseSensor.h:122
Definition: RGBDSensorConfig.h:34
virtual std::string GetFilename() const override
Get filename being written.
Definition: RealSenseSensor.h:127