OrbbecSDK  1.5.7
OrbbecSDK: Software-Development-Kit for Orbbec 3D-Sensor devices
StreamProfile.hpp
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include "Types.hpp"
13 
14 #include <iostream>
15 #include <memory>
16 
17 struct StreamProfileImpl;
18 struct StreamProfileListImpl;
19 
20 namespace ob {
21 
22 class VideoStreamProfile;
23 class GyroStreamProfile;
24 class AccelStreamProfile;
25 class Config;
26 
27 class OB_EXTENSION_API StreamProfile : public std::enable_shared_from_this<StreamProfile> {
28 protected:
29  std::unique_ptr<StreamProfileImpl> impl_;
30 
31 public:
32  StreamProfile(std::unique_ptr<StreamProfileImpl> impl);
33  StreamProfile(StreamProfile &streamProfile);
34  ~StreamProfile() noexcept;
35 
47  OBFormat format() const;
59  OBStreamType type() const;
60 
74  template <typename T> bool is();
75 
89  template <typename T> std::shared_ptr<T> as() {
90  if(!is<T>())
91  throw "unsupported operation, object's type is not require type";
92 
93  return std::static_pointer_cast<T>(std::const_pointer_cast<StreamProfile>(shared_from_this()));
94  }
95 
96  friend class Sensor;
97  friend class Config;
98  friend class Pipeline;
99 };
100 
102 public:
104  ~VideoStreamProfile() noexcept;
105 
117  uint32_t fps() const;
129  uint32_t width() const;
141  uint32_t height() const;
142 };
143 
145 public:
147  ~AccelStreamProfile() noexcept;
148 
160  OBAccelFullScaleRange fullScaleRange() const;
161 
173  OBAccelSampleRate sampleRate() const;
174 };
175 
177 public:
179  ~GyroStreamProfile() noexcept;
180 
192  OBGyroFullScaleRange fullScaleRange() const;
193 
205  OBGyroSampleRate sampleRate() const;
206 };
207 
208 template <typename T> bool StreamProfile::is() {
209  switch(this->type()) {
210  case OB_STREAM_VIDEO:
211  case OB_STREAM_IR:
212  case OB_STREAM_IR_LEFT:
213  case OB_STREAM_IR_RIGHT:
214  case OB_STREAM_COLOR:
215  case OB_STREAM_DEPTH:
216  return typeid(T) == typeid(VideoStreamProfile);
217  case OB_STREAM_ACCEL:
218  return typeid(T) == typeid(AccelStreamProfile);
219  case OB_STREAM_GYRO:
220  return typeid(T) == typeid(GyroStreamProfile);
221  default:
222  break;
223  }
224  return false;
225 }
226 
228 protected:
229  std::unique_ptr<StreamProfileListImpl> impl_;
230 
231 public:
232  StreamProfileList(std::unique_ptr<StreamProfileListImpl> impl);
233  ~StreamProfileList() noexcept;
234 
246  uint32_t count() const;
247 
261  const std::shared_ptr<StreamProfile> getProfile(uint32_t index);
262 
283  const std::shared_ptr<VideoStreamProfile> getVideoStreamProfile(int width = 0, int height = 0, OBFormat format = OB_FORMAT_UNKNOWN, int fps = 0);
284 };
285 
286 } // namespace ob
OBFormat
Enumeration value describing the pixel format.
Definition: ObTypes.h:221
enum OBGyroSampleRate OBAccelSampleRate
OBAccelFullScaleRange
Accelerometer range enumeration.
Definition: ObTypes.h:596
Definition: Context.hpp:20
std::unique_ptr< StreamProfileListImpl > impl_
Provide SDK structure and enumeration constant definition (depending on libobsensor/h/ObTypes.h)
OBGyroFullScaleRange
Enumeration of gyroscope ranges.
Definition: ObTypes.h:577
bool is()
Check if frame object is compatible with the given type.
OBStreamType
Enumeration value describing the type of data stream.
Definition: ObTypes.h:178
std::unique_ptr< StreamProfileImpl > impl_
OBGyroSampleRate
Enumeration of IMU sample rate values ​​(gyroscope or accelerometer)
Definition: ObTypes.h:551
#define OB_EXTENSION_API
Definition: ObTypes.h:25