DVSenseDriver  1.0.0
The SDK for dvsense products.
DvsCamera.hpp
1 #ifndef DVSCAMERA_HPP
2 #define DVSCAMERA_HPP
3 
4 #include <list>
5 #include <string>
6 #include <memory>
7 #include <iostream>
8 #include <mutex>
9 #include <atomic>
10 #include "DvsenseHal/camera/DvsCameraUtils.hpp"
11 #include "DvsenseHal/EventStream/RawEventStreamFormat.hpp"
12 #include "DvsenseBase/EventBase/EventTypes.hpp"
13 
14 #ifdef _WIN32
15 #define DVSENSE_API __declspec(dllexport)
16 #else
17 #define DVSENSE_API
18 #endif // _WIN32
19 namespace dvsense
20 {
21 
22  class DvsCameraManager;
23 
28  #ifdef _WIN32
29  enum DVSENSE_API BatchConditionType
30  #else
32  #endif // _WIN32
33  {
36  N_US
37  };
38 
43  #ifdef _WIN32
44  enum DVSENSE_API CameraStatus
45  #else
47  #endif // _WIN32
48  {
49  STOPPED = 0,
50  STARTED = 1
51  };
52 
58  class DVSENSE_API DvsCamera
59  {
60  private:
61  friend DvsCameraManager;
62 
63  public:
71 
78  virtual const bool isConnected() = 0;
79 
87  {
88  return cameraDesc_;
89  }
90 
99  virtual uint32_t addEventsStreamHandleCallback(EventsStreamHandleCallback cb);
100 
111  virtual bool removeEventsStreamHandleCallback(uint32_t callback_id);
112 
128  virtual bool getNextBatch(Event2DVector& event_batch);
129 
136  virtual void setBatchEventsNum(uint64_t n);
137 
144  virtual void setBatchEventsTime(uint64_t n);
145 
152  virtual int start() = 0;
153 
160  virtual int stop() = 0;
161 
170  virtual int startRecording(std::string file_path) = 0;
171 
178  virtual int stopRecording() = 0;
179 
186  virtual uint16_t getWidth() = 0;
187 
194  virtual uint16_t getHeight() = 0;
195 
196  protected:
204 
212 
219  virtual int init() = 0;
220 
221  // callbacks map
222  std::unordered_map<uint32_t, EventsStreamHandleCallback> callbacks_map_;
223  uint32_t callback_id_ = 0;
224  std::mutex callbacks_mutex_;
225 
226  //get batch events
227  std::atomic<BatchConditionType> get_batch_conditon_ = BatchConditionType::NO_CONDITION;
228  uint64_t accumulate_events_num_ = 128 * 1024;//By default, 128K events are collected each time
229  uint64_t accumulate_events_time_ = 10 * 1000; //us. The default value is 10ms each time
230 
231  };
232 
233 } // namespace dvsense
234 
235 #endif // DVSCAMERA_HPP
相机管理器类
Definition: DvsCameraManager.hpp:29
DVS相机的接口类
Definition: DvsCamera.hpp:59
virtual int startRecording(std::string file_path)=0
开始记录事件
virtual int start()=0
启动相机
DvsCamera(CameraDescription cameraDesc)
构造函数
const CameraDescription getDvsDesc()
获取相机描述
Definition: DvsCamera.hpp:86
CameraDescription cameraDesc_
获取相机描述
Definition: DvsCamera.hpp:211
virtual bool removeEventsStreamHandleCallback(uint32_t callback_id)
通过id移除一个回调函数
virtual int init()=0
打开相机时,应该初始化
virtual void setBatchEventsTime(uint64_t n)
设置获取事件的时间间隔
std::unordered_map< uint32_t, EventsStreamHandleCallback > callbacks_map_
Definition: DvsCamera.hpp:222
virtual int stopRecording()=0
停止记录事件
virtual uint32_t addEventsStreamHandleCallback(EventsStreamHandleCallback cb)
添加一个回调函数来处理事件
virtual int stop()=0
停止相机
std::mutex callbacks_mutex_
Definition: DvsCamera.hpp:224
virtual uint16_t getWidth()=0
获取相机传感器的宽度
virtual RawEventStreamFormat getRawEventStreamFormat()=0
获取原始事件流的格式
virtual const bool isConnected()=0
检查相机是否连接
virtual uint16_t getHeight()=0
获取相机传感器的高度
virtual void setBatchEventsNum(uint64_t n)
设置需要获取的事件数量
virtual bool getNextBatch(Event2DVector &event_batch)
获取下一批事件 在使用getNextBatch函数之前,您需要使用 setBatchEventsNum 设置需要获取的事件数量, 或者使用 setBatchEventsTime 设置需要获取事件的时间间...
描述直接从相机读取的原始事件流格式和几何形状的类,在解码之前
Definition: RawEventStreamFormat.hpp:44
Definition: TypeUtils.hpp:7
CameraStatus
相机状态,STOPPED 或 STARTED
Definition: DvsCamera.hpp:48
@ STOPPED
Definition: DvsCamera.hpp:49
@ STARTED
Definition: DvsCamera.hpp:50
BatchConditionType
事件批次的切割条件,n个事件(N_EVENTS) 或 固定事件(N_US)
Definition: DvsCamera.hpp:33
@ NO_CONDITION
Definition: DvsCamera.hpp:34
@ N_US
Definition: DvsCamera.hpp:36
@ N_EVENTS
Definition: DvsCamera.hpp:35
用于描述相机信息的结构体
Definition: DvsCameraUtils.hpp:39