OrbbecSDK  1.0.0
Frame.hpp
浏览该文件的文档.
1 
6 #pragma once
7 
8 #include "Types.hpp"
9 
10 #include <memory>
11 #include <typeinfo>
12 
27 struct FrameImpl;
28 
29 namespace ob {
30 class StreamProfile;
31 class Filter;
32 
33 class OB_EXTENSION_API Frame : public std::enable_shared_from_this< Frame > {
34 protected:
35  std::unique_ptr< FrameImpl > impl_;
36 
37 public:
38  Frame( std::unique_ptr< FrameImpl > impl );
39  Frame( Frame& frame );
40 
41  virtual ~Frame();
47  virtual OBFrameType type();
48 
54  virtual OBFormat format();
55 
61  virtual uint64_t index();
62 
68  virtual void* data();
69 
75  virtual uint32_t dataSize();
76 
83  template < typename T > bool is();
84 
91  template < typename T > std::shared_ptr< T > as() {
92  if ( !is< T >() )
93  return nullptr;
94 
95  return std::static_pointer_cast< T >( std::const_pointer_cast< Frame >( shared_from_this() ) );
96  }
97 
98 private:
99  friend class Filter;
100 };
101 
102 class OB_EXTENSION_API VideoFrame : public Frame {
103 public:
104  VideoFrame( Frame& frame );
105  virtual ~VideoFrame(){};
106 
112  uint32_t width();
113 
119  uint32_t height();
120 
126  uint64_t timeStamp();
127 
133  uint64_t systemTimeStamp();
134 
140  void* metadata();
141 
147  uint32_t metadataSize();
148 };
149 
150 class OB_EXTENSION_API ColorFrame : public VideoFrame {
151 public:
152  ColorFrame( Frame& frame );
153  ~ColorFrame(){};
154 };
155 
156 class OB_EXTENSION_API DepthFrame : public VideoFrame {
157 public:
158  DepthFrame( Frame& frame );
159  ~DepthFrame(){};
160 
168  float getValueScale();
169 };
170 
171 class OB_EXTENSION_API IRFrame : public VideoFrame {
172 public:
173  IRFrame( Frame& frame );
174  virtual ~IRFrame(){};
175 };
176 
177 class OB_EXTENSION_API FrameSet : public Frame {
178 
179 public:
180  // FrameSet();
181  FrameSet( Frame& frame );
182  ~FrameSet();
183 
189  uint32_t frameCount();
190 
196  std::shared_ptr< DepthFrame > depthFrame();
197 
203  std::shared_ptr< ColorFrame > colorFrame();
204 
210  std::shared_ptr< IRFrame > irFrame();
211 
218  std::shared_ptr< Frame > getFrame( OBSensorType sensorType );
219 
220  friend class Pipeline;
221  friend class Filter;
222 };
223 
224 template < typename T > bool Frame::is() {
225  switch ( this->type() ) {
226  case OB_FRAME_IR:
227  return ( typeid( T ) == typeid( IRFrame ) || typeid( T ) == typeid( VideoFrame ) );
228  case OB_FRAME_DEPTH:
229  return ( typeid( T ) == typeid( DepthFrame ) || typeid( T ) == typeid( VideoFrame ) );
230  case OB_FRAME_COLOR:
231  return ( typeid( T ) == typeid( ColorFrame ) || typeid( T ) == typeid( VideoFrame ) );
232  case OB_FRAME_SET:
233  return ( typeid( T ) == typeid( FrameSet ) );
234  default:
235  break;
236  }
237  return false;
238 }
239 } // namespace ob
Definition: Context.hpp:15
bool is()
检查帧对象的运行时类型是否与给定类型兼容
Definition: Frame.hpp:224
提供SDK的结构体、枚举常量定义(依赖libobsensor/h/ObTypes.h)
std::shared_ptr< T > as()
帧对象类型转换
Definition: Frame.hpp:91