DvsenseDriver  1.0.3
The SDK for dvsense products.
Loading...
Searching...
No Matches
Camera Sample

You can refer to the example program for the operation of the camera on and off. The following provides the explanation of different acquisition event interfaces.

Callback Interface

Camera provides addEventsStreamHandleCallback interface, this interface can access to the flow of events in real time.

The following is a usage example:

camera->addEventsStreamHandleCallback([&img](const dvsense::Event2D*begin,const dvsense::Event2D*end) {
// do something or just copy data
for (autoit=begin; it!=end; ++it) {
img.at<cv::Vec3b>(it->y,it->x) = (it->polarity) ?color_on:color_off;
}
});

Warning: When using the callback function interface, it is necessary to reduce the execution time of the callback function as much as possible, otherwise it will cause data accumulation and cause the program to crash.

You can add multiple callback functions using the addEventsStreamHandleCallback function, which will execute the callback functions you registered in the order they were registered when event stream is available. You can also record the ID number of the callback function using the return value of addEventsStreamHandleCallback, and then delete the callback function you no longer need by using the removeEventsStreamHandleCallback(id) function.

autocb_id=camera->addEventsStreamHandleCallback([](const dvsense::Event2D*begin,const dvsense::Event2D*end) {
// do something or just copy data
});
camera->removeEventsStreamHandleCallback(cb_id)

Synchronous Interface

Camera provides getNextBatch interface, You can set the number or time to get the events, and then get the specified event data through the getNextBatch interface.

If you want to get a fixed number of events, you need to set the number of events you need through the setAccumulateEventsNum interface in advance,

camera->setAccumulateEventsNum(1000); // set 1000 events to get

also if you want to get a fixed time of events, you can set the interval you need through the setAccumulateEventsTime interface

camera->setAccumulateEventTime(1000); // Example Set the event interval of 1000us

Once the setup is complete, you need to retrieve the data by calling the getNextBatch interface

```cpp

std::threadget_events_thread= std::thread([&camera,&get_events,&stop_application]{

    while (!stop_application) {

        if (camera->getNextBatch(get_events))

        {

            // do something

        }

    }

});