| OrbbecSDK 1.10.18 OrbbecSDK: Software-Development-Kit for Orbbec 3D Cameras

Loading...
Searching...
No Matches
StreamProfile.hpp
Go to the documentation of this file.
1
5#pragma once
6
7#include "Types.hpp"
8
9#include <iostream>
10#include <memory>
11
12 struct StreamProfileImpl;
13 struct StreamProfileListImpl;
14
15 namespace ob {
16
17 class VideoStreamProfile;
18 class GyroStreamProfile;
19 class AccelStreamProfile;
20 class Config;
21
22 class OB_EXTENSION_API StreamProfile : public std::enable_shared_from_this<StreamProfile> {
23 protected:
24 std::unique_ptr<StreamProfileImpl> impl_;
25
26 public:
27 StreamProfile(std::unique_ptr<StreamProfileImpl> impl);
28 StreamProfile(StreamProfile &streamProfile);
29 virtual ~StreamProfile() noexcept;
30
36 OBFormat format() const;
37
43 OBStreamType type() const;
44
50 OBExtrinsic getExtrinsicTo(std::shared_ptr<StreamProfile> target);
51
58 template <typename T> bool is();
59
66 template <typename T> std::shared_ptr<T> as() {
67 if(!is<T>()) {
68 throw std::runtime_error("Unsupported operation. Object's type is not the required type.");
69 }
70
71 return std::static_pointer_cast<T>(std::const_pointer_cast<StreamProfile>(shared_from_this()));
72 }
73
74 friend class Sensor;
75 friend class Config;
76 friend class Pipeline;
77};
78
82 class OB_EXTENSION_API VideoStreamProfile : public StreamProfile {
83 public:
84 explicit VideoStreamProfile(StreamProfile &profile);
85
86 explicit VideoStreamProfile(std::unique_ptr<StreamProfileImpl> impl);
87
88 ~VideoStreamProfile() noexcept override;
89
95 uint32_t fps() const;
96
102 uint32_t width() const;
103
109 uint32_t height() const;
110
116 OBCameraIntrinsic getIntrinsic();
117
124 OBCameraDistortion getDistortion();
125};
126
130class OB_EXTENSION_API AccelStreamProfile : public StreamProfile {
131 public:
132 explicit AccelStreamProfile(StreamProfile &profile);
133
134 explicit AccelStreamProfile(std::unique_ptr<StreamProfileImpl> impl);
135
136 ~AccelStreamProfile() noexcept override;
137
143 OBAccelFullScaleRange fullScaleRange() const;
144
150 OBAccelSampleRate sampleRate() const;
151
157 OBAccelIntrinsic getIntrinsic();
158};
159
163class OB_EXTENSION_API GyroStreamProfile : public StreamProfile {
164 public:
165 explicit GyroStreamProfile(StreamProfile &profile);
166
167 explicit GyroStreamProfile(std::unique_ptr<StreamProfileImpl> impl);
168 ~GyroStreamProfile() noexcept override;
169
175 OBGyroFullScaleRange fullScaleRange() const;
176
182 OBGyroSampleRate sampleRate() const;
183
189 OBGyroIntrinsic getIntrinsic();
190};
191
192template <typename T> bool StreamProfile::is() {
193 switch(this->type()) {
194 case OB_STREAM_VIDEO:
195 case OB_STREAM_IR:
196 case OB_STREAM_IR_LEFT:
197 case OB_STREAM_IR_RIGHT:
198 case OB_STREAM_COLOR:
199 case OB_STREAM_DEPTH:
200 case OB_STREAM_RAW_PHASE:
201 return typeid(T) == typeid(VideoStreamProfile);
202 case OB_STREAM_ACCEL:
203 return typeid(T) == typeid(AccelStreamProfile);
204 case OB_STREAM_GYRO:
205 return typeid(T) == typeid(GyroStreamProfile);
206 default:
207 break;
208 }
209 return false;
210}
211
212 class OB_EXTENSION_API StreamProfileList {
213 protected:
214 std::unique_ptr<StreamProfileListImpl> impl_;
215
216 public:
217 explicit StreamProfileList(std::unique_ptr<StreamProfileListImpl> impl);
218 ~StreamProfileList() noexcept;
219
225 uint32_t count() const;
226
233 const std::shared_ptr<StreamProfile> getProfile(uint32_t index);
234
245 const std::shared_ptr<VideoStreamProfile> getVideoStreamProfile(int width = OB_WIDTH_ANY, int height = OB_HEIGHT_ANY, OBFormat format = OB_FORMAT_ANY,
246 int fps = OB_FPS_ANY);
247
255 const std::shared_ptr<AccelStreamProfile> getAccelStreamProfile(OBAccelFullScaleRange fullScaleRange, OBAccelSampleRate sampleRate);
256
264 const std::shared_ptr<GyroStreamProfile> getGyroStreamProfile(OBGyroFullScaleRange fullScaleRange, OBGyroSampleRate sampleRate);
265};
266
267} // namespace ob
OBGyroFullScaleRange
OBGyroFullScaleRange
Enumeration of gyroscope ranges.
Definition ObTypes.h:607
OBFormat
OBFormat
Enumeration value describing the pixel format.
Definition ObTypes.h:216
OBAccelSampleRate
enum OBGyroSampleRate OBAccelSampleRate
OBGyroSampleRate
OBGyroSampleRate
Enumeration of IMU sample rate values (gyroscope or accelerometer)
Definition ObTypes.h:584
OBStreamType
OBStreamType
Enumeration value describing the type of data stream.
Definition ObTypes.h:179
OB_STREAM_RAW_PHASE
@ OB_STREAM_RAW_PHASE
Definition ObTypes.h:189
OB_STREAM_GYRO
@ OB_STREAM_GYRO
Definition ObTypes.h:186
OB_STREAM_IR
@ OB_STREAM_IR
Definition ObTypes.h:182
OB_STREAM_DEPTH
@ OB_STREAM_DEPTH
Definition ObTypes.h:184
OB_STREAM_IR_RIGHT
@ OB_STREAM_IR_RIGHT
Definition ObTypes.h:188
OB_STREAM_IR_LEFT
@ OB_STREAM_IR_LEFT
Definition ObTypes.h:187
OB_STREAM_VIDEO
@ OB_STREAM_VIDEO
Definition ObTypes.h:181
OB_STREAM_ACCEL
@ OB_STREAM_ACCEL
Definition ObTypes.h:185
OB_STREAM_COLOR
@ OB_STREAM_COLOR
Definition ObTypes.h:183
OBAccelFullScaleRange
OBAccelFullScaleRange
Enumeration of accelerometer ranges.
Definition ObTypes.h:623
OB_WIDTH_ANY
#define OB_WIDTH_ANY
Definition ObTypes.h:74
OB_EXTENSION_API
#define OB_EXTENSION_API
Definition ObTypes.h:28
OB_FPS_ANY
#define OB_FPS_ANY
Definition ObTypes.h:76
OB_HEIGHT_ANY
#define OB_HEIGHT_ANY
Definition ObTypes.h:75
OB_FORMAT_ANY
#define OB_FORMAT_ANY
Definition ObTypes.h:77
Types.hpp
Provides SDK structure and enumeration constant definitions (depending on libobsensor/h/ObTypes....
ob::AccelStreamProfile
Class representing an accelerometer stream profile.
Definition StreamProfile.hpp:130
ob::AccelStreamProfile::~AccelStreamProfile
~AccelStreamProfile() noexcept override
ob::AccelStreamProfile::AccelStreamProfile
AccelStreamProfile(std::unique_ptr< StreamProfileImpl > impl)
ob::AccelStreamProfile::AccelStreamProfile
AccelStreamProfile(StreamProfile &profile)
ob::Config
Config class for configuring pipeline parameters.
Definition Pipeline.hpp:210
ob::GyroStreamProfile
Class representing a gyroscope stream profile.
Definition StreamProfile.hpp:163
ob::GyroStreamProfile::GyroStreamProfile
GyroStreamProfile(StreamProfile &profile)
ob::GyroStreamProfile::GyroStreamProfile
GyroStreamProfile(std::unique_ptr< StreamProfileImpl > impl)
ob::GyroStreamProfile::~GyroStreamProfile
~GyroStreamProfile() noexcept override
ob::Pipeline
Definition Pipeline.hpp:28
ob::Sensor
Definition Sensor.hpp:31
ob::StreamProfileList
Definition StreamProfile.hpp:212
ob::StreamProfileList::~StreamProfileList
~StreamProfileList() noexcept
ob::StreamProfileList::impl_
std::unique_ptr< StreamProfileListImpl > impl_
Definition StreamProfile.hpp:214
ob::StreamProfileList::StreamProfileList
StreamProfileList(std::unique_ptr< StreamProfileListImpl > impl)
ob::StreamProfile
Definition StreamProfile.hpp:22
ob::StreamProfile::~StreamProfile
virtual ~StreamProfile() noexcept
ob::StreamProfile::impl_
std::unique_ptr< StreamProfileImpl > impl_
Definition StreamProfile.hpp:24
ob::StreamProfile::StreamProfile
StreamProfile(StreamProfile &streamProfile)
ob::StreamProfile::StreamProfile
StreamProfile(std::unique_ptr< StreamProfileImpl > impl)
ob::VideoStreamProfile
Class representing a video stream profile.
Definition StreamProfile.hpp:82
ob::VideoStreamProfile::VideoStreamProfile
VideoStreamProfile(std::unique_ptr< StreamProfileImpl > impl)
ob::VideoStreamProfile::~VideoStreamProfile
~VideoStreamProfile() noexcept override
ob::VideoStreamProfile::VideoStreamProfile
VideoStreamProfile(StreamProfile &profile)
ob
Definition Context.hpp:16
OBAccelIntrinsic
Structure for accelerometer intrinsic parameters.
Definition ObTypes.h:392
OBCameraDistortion
Structure for distortion parameters.
Definition ObTypes.h:417
OBCameraIntrinsic
Structure for camera intrinsic parameters.
Definition ObTypes.h:380
OBD2CTransform
Structure for rotation/transformation.
Definition ObTypes.h:454
OBGyroIntrinsic
Structure for gyroscope intrinsic parameters.
Definition ObTypes.h:405