![]() |
DvsenseDriver
1.0.3
The SDK for dvsense products.
|
This part introduces how to control the camera through the API interface. And it also presents two methods for real-time processing of camera data, namely synchronous and asynchronous methods.
In the DvsenseDriver, all cameras are uniformly managed by using 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, the camera does not start data streaming by default, and you need to manually start it.
Attention!! Before starting the data streaming, please refer to the following Acquire And Process Events register Asynchronously Process Events callback function, or set Synchronously Process Events rules
In the DvsenseDriver, two methods for acquiring and processing camera data are provided to meet different needs and scenarios.
The synchronous and asynchronous processing methods can be carried out simultaneously. However, only one of the two settings for event acquisition in the synchronous method can be used at a time. That is to say, you can both register a callback function and actively obtain the next batch of data using the dvsense::DvsCamera::getNextBatch function. Nevertheless, the dvsense::DvsCamera::getNextBatch function can only be set to one of the two settings: acquiring events for a fixed time or a fixed number.
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 will be 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, you must minimize the execution time of the callback function as much as possible. Otherwise, it will lead to data accumulation and cause the program to crash.
You can use the dvsense::DvsCamera::addEventsStreamHandleCallback function to add multiple callback functions. When the event stream is available, these callback functions will be executed sequentially in the order of registration. You can also record the ID number of the callback function, which is the return value of dvsense::DvsCamera::addEventsStreamHandleCallback, and then remove the callback functions that are no longer needed through the dvsense::DvsCamera::removeEventsStreamHandleCallback function.
The camera provides the dvsense::DvsCamera::getNextBatch interface. You can set the number or time period for event acquisition, and then obtain the specified event data through the dvsense::DvsCamera::getNextBatch interface.
If you want to acquire a fixed number of events, you need to set the required number of events in advance via the dvsense::DvsCamera::setBatchEventsNum interface.
In addition, if you want to acquire events within a fixed time period, you can set the required time interval through the dvsense::DvsCamera::setBatchEventsTime interface.
Once the settings are completed, you need to call the dvsense::DvsCamera::getNextBatch interface to obtain the data.
After the camera starts streaming data, you can use dvsense::DvsCamera::startRecording and dvsense::DvsCamera::stopRecording to stream the camera's raw data into a raw file. raw file,This is for subsequent playback and processing.