| OrbbecSDK 1.5.7 OrbbecSDK: Software-Development-Kit for Orbbec 3D-Sensor devices

- 首页
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

Frame.hpp
浏览该文件的文档.
1
11 #pragma once
12
13 #include "Types.hpp"
14
15 #include <memory>
16 #include <iostream>
17 #include <typeinfo>
18
36 struct FrameImpl;
37
38 namespace ob {
39 class StreamProfile;
40 class Filter;
41 class FrameHelper;
42
43 typedef std::function<void(void *buffer, void *context)> BufferDestroyCallback;
44
45 class OB_EXTENSION_API Frame : public std::enable_shared_from_this<Frame> {
46 protected:
47 std::unique_ptr<FrameImpl> impl_;
48
49 public:
50 Frame(std::unique_ptr<FrameImpl> impl);
51 Frame(Frame &frame);
52
53 virtual ~Frame() noexcept;
65 virtual OBFrameType type();
66
78 virtual OBFormat format();
79
91 virtual uint64_t index();
92
104 virtual void *data();
105
119 virtual uint32_t dataSize();
120
132 uint64_t timeStamp();
133
145 uint64_t timeStampUs();
146
158 uint64_t systemTimeStamp();
159
173 template <typename T> bool is();
174
188 template <typename T> std::shared_ptr<T> as() {
189 if(!is<T>())
190 throw "unsupported operation, object's type is not require type";
191
192 return std::static_pointer_cast<T>(std::const_pointer_cast<Frame>(shared_from_this()));
193 }
194
195 private:
196 friend class Filter;
197 friend class Recorder;
198 friend class FrameHelper;
199 };
200
201 class OB_EXTENSION_API VideoFrame : public Frame {
202 public:
203 VideoFrame(Frame &frame);
204 virtual ~VideoFrame() noexcept {};
205
217 uint32_t width();
218
230 uint32_t height();
231
243 void *metadata();
244
256 uint32_t metadataSize();
257
271 uint8_t pixelAvailableBitSize();
272 };
273
274 class OB_EXTENSION_API ColorFrame : public VideoFrame {
275 public:
276 ColorFrame(Frame &frame);
277 ~ColorFrame() noexcept {};
278 };
279
280 class OB_EXTENSION_API DepthFrame : public VideoFrame {
281 public:
282 DepthFrame(Frame &frame);
283 ~DepthFrame() noexcept {};
284
298 float getValueScale();
299 };
300
301 class OB_EXTENSION_API IRFrame : public VideoFrame {
302 public:
303 IRFrame(Frame &frame);
304 virtual ~IRFrame() noexcept {};
305
306 public:
307 OBSensorType getDataSource();
308 };
309
310 class OB_EXTENSION_API PointsFrame : public Frame {
311 public:
312 PointsFrame(Frame &frame);
313 ~PointsFrame() noexcept {};
314
331 float getPositionValueScale();
332 };
333
334 class OB_EXTENSION_API FrameSet : public Frame {
335
336 public:
337 // FrameSet();
338 FrameSet(Frame &frame);
339 ~FrameSet() noexcept;
340
352 uint32_t frameCount();
353
365 std::shared_ptr<DepthFrame> depthFrame();
366
378 std::shared_ptr<ColorFrame> colorFrame();
379
391 std::shared_ptr<IRFrame> irFrame();
392
404 std::shared_ptr<PointsFrame> pointsFrame();
405
419 std::shared_ptr<Frame> getFrame(OBFrameType frameType);
420
421 friend class Pipeline;
422 friend class Filter;
423 };
424
425 class OB_EXTENSION_API AccelFrame : public Frame {
426 public:
427 AccelFrame(Frame &frame);
428 ~AccelFrame() noexcept = default;
429
441 OBAccelValue value();
442
454 float temperature();
455 };
456
457 class OB_EXTENSION_API GyroFrame : public Frame {
458 public:
459 GyroFrame(Frame &frame);
460 ~GyroFrame() noexcept = default;
461
473 OBGyroValue value();
474
486 float temperature();
487 };
488
489 class OB_EXTENSION_API FrameHelper {
490 public:
491 FrameHelper();
492 ~FrameHelper();
503 static std::shared_ptr<Frame> createFrameFromBuffer(OBFormat format, uint32_t frameWidth, uint32_t frameHeight, uint8_t *buffer, uint32_t bufferSize,
504 BufferDestroyCallback destroyCallback, void *destroyCallbackContext);
505
511 static std::shared_ptr<Frame> createFrameSet();
512
520 static void pushFrame(std::shared_ptr<Frame> frameSet, OBFrameType frameType, std::shared_ptr<Frame> frame);
521
528 static void setFrameSystemTimestamp(std::shared_ptr<Frame> frame, uint64_t systemTimestamp);
529
536 static void setFrameDeviceTimestamp(std::shared_ptr<Frame> frame, uint64_t deviceTimestamp);
537
544 static void setFrameDeviceTimestampUs(std::shared_ptr<Frame> frame, uint64_t deviceTimestampUs);
545 };
546
547 template <typename T> bool Frame::is() {
548 switch(this->type()) {
549 case OB_FRAME_IR_LEFT: // follow
550 case OB_FRAME_IR_RIGHT: // follow
551 case OB_FRAME_IR:
552 return (typeid(T) == typeid(IRFrame) || typeid(T) == typeid(VideoFrame));
553 case OB_FRAME_DEPTH:
554 return (typeid(T) == typeid(DepthFrame) || typeid(T) == typeid(VideoFrame));
555 case OB_FRAME_COLOR:
556 return (typeid(T) == typeid(ColorFrame) || typeid(T) == typeid(VideoFrame));
557 case OB_FRAME_GYRO:
558 return (typeid(T) == typeid(GyroFrame));
559 case OB_FRAME_ACCEL:
560 return (typeid(T) == typeid(AccelFrame));
561 case OB_FRAME_SET:
562 return (typeid(T) == typeid(FrameSet));
563 case OB_FRAME_POINTS:
564 return (typeid(T) == typeid(PointsFrame));
565 default:
566 std::cout << "ob::Frame::is() not catch frame type: " << (int)this->type() << std::endl;
567 break;
568 }
569 return false;
570 }
571 } // namespace ob
OB_FRAME_IR_RIGHT
Definition: ObTypes.h:210
OBFormat
OBFormat
描述像素格式的枚举值
Definition: ObTypes.h:221
ob::Recorder
Definition: RecordPlayback.hpp:27
ob::Frame
Definition: Frame.hpp:45
OB_FRAME_GYRO
Definition: ObTypes.h:208
ob::FrameSet
Definition: Frame.hpp:334
ob::VideoFrame
Definition: Frame.hpp:201
ob::DepthFrame::~DepthFrame
~DepthFrame() noexcept
Definition: Frame.hpp:283
OB_FRAME_COLOR
Definition: ObTypes.h:203
OBAccelValue
加速度计及陀螺仪的数据结构体
Definition: ObTypes.h:611
ob::Filter
Definition: Filter.hpp:21
ob
Definition: Context.hpp:20
OB_FRAME_IR_LEFT
Definition: ObTypes.h:209
OBSensorType
OBSensorType
描述传感器类型的枚举值
Definition: ObTypes.h:159
ob::ColorFrame::~ColorFrame
~ColorFrame() noexcept
Definition: Frame.hpp:277
ob::PointsFrame
Definition: Frame.hpp:310
Types.hpp
提供SDK的结构体、枚举常量定义（依赖libobsensor/h/ObTypes.h）
ob::BufferDestroyCallback
std::function< void(void *buffer, void *context)> BufferDestroyCallback
Definition: Frame.hpp:41
OB_FRAME_DEPTH
Definition: ObTypes.h:204
ob::PointsFrame::~PointsFrame
~PointsFrame() noexcept
Definition: Frame.hpp:313
OB_FRAME_ACCEL
Definition: ObTypes.h:205
OB_FRAME_POINTS
Definition: ObTypes.h:207
ob::GyroFrame
Definition: Frame.hpp:457
ob::AccelFrame
Definition: Frame.hpp:425
OB_FRAME_IR
Definition: ObTypes.h:202
OBFrameType
OBFrameType
描述 Frame 类型枚举值
Definition: ObTypes.h:199
ob::Frame::is
bool is()
检查帧对象的运行时类型是否与给定类型兼容
Definition: Frame.hpp:547
ob::VideoFrame::~VideoFrame
virtual ~VideoFrame() noexcept
Definition: Frame.hpp:204
ob::ColorFrame
Definition: Frame.hpp:274
OB_FRAME_SET
Definition: ObTypes.h:206
ob::Pipeline
Definition: Pipeline.hpp:32
ob::FrameHelper
Definition: Frame.hpp:489
ob::IRFrame::~IRFrame
virtual ~IRFrame() noexcept
Definition: Frame.hpp:304
ob::IRFrame
Definition: Frame.hpp:301
ob::DepthFrame
Definition: Frame.hpp:280
ob::Frame::impl_
std::unique_ptr< FrameImpl > impl_
Definition: Frame.hpp:47
OB_EXTENSION_API
#define OB_EXTENSION_API
Definition: ObTypes.h:25