![]() |
DvsenseDriver
1.2.4
The SDK for dvsense products.
|
This part introduces how to control the camera through the API interface. It also presents two methods for real-time processing of camera data: synchronous and asynchronous processing.
In DVSenseDriver, all cameras are managed through the dvsense::DvsCameraManager class.
dvsense::CameraDescription contains information such as the manufacturer, model, and serial number of the camera.
The dvsense::DvsCameraManager::openCamera interface can be used to open a specific camera by its serial number.
The dvsense::CameraDevice is an easy-to-use wrapper for dvsense::DvsCamera. It is defined as typedef std::shared_ptr<DvsCamera> CameraDevice.
After opening the camera, data streaming does not start by default, so you need to start it manually.
Attention: Before starting data streaming, please either register the callback function described in Asynchronously Process Events or configure the rules described in Synchronously Process Events.
DVSenseDriver provides two methods for acquiring and processing camera data to meet different needs and scenarios.
The synchronous and asynchronous processing methods can be used at the same time. However, only one of the two synchronous acquisition modes can be active at once. In other words, you can both register callback functions and actively obtain the next batch of data through dvsense::DvsCamera::getNextBatch, but getNextBatch can only be configured for either fixed-time or fixed-count acquisition.
The camera provides the dvsense::DvsCamera::addEventsStreamHandleCallback interface, which allows real-time access to the event stream. Whenever a small packet of events is successfully transmitted and decoded, the registered callback function is invoked.
The following is a usage example. In this example, the positions where events occur in a blank image img are assigned colors for subsequent visualization.
Warning: When using the callback function interface, keep callback execution time as short as possible. Otherwise, data may accumulate and cause the program to crash.
You can use dvsense::DvsCamera::addEventsStreamHandleCallback to add multiple callback functions. When the event stream is available, these callback functions are executed sequentially in registration order. You can also record the callback ID returned by dvsense::DvsCamera::addEventsStreamHandleCallback and remove callbacks that are no longer needed through dvsense::DvsCamera::removeEventsStreamHandleCallback.
The camera provides the dvsense::DvsCamera::getNextBatch interface. You can set either the number of events or the acquisition time window, and then obtain the corresponding event data through dvsense::DvsCamera::getNextBatch.
If you want to acquire a fixed number of events, set the required number through dvsense::DvsCamera::setBatchEventsNum.
If you want to acquire events within a fixed time period, set the required time interval through dvsense::DvsCamera::setBatchEventsTime.
Once the settings are completed, call dvsense::DvsCamera::getNextBatch to obtain the data.
After the camera starts streaming data, you can use dvsense::DvsCamera::startRecording and dvsense::DvsCamera::stopRecording to write the camera's raw data into a raw file. See raw file for subsequent playback and processing.