OpenEV
Extending OpenCV to event-based vision
Loading...
Searching...
No Matches
example-davis.cpp

This is an example of how to use the Davis class.

#include <cstdlib>
#include <iostream>
#include <opencv2/core.hpp>
#include <opencv2/core/cvstd.inl.hpp>
#include <opencv2/core/mat.hpp>
#include <opencv2/core/mat.inl.hpp>
#include <opencv2/core/matx.hpp>
#include <opencv2/core/saturate.hpp>
#include <opencv2/core/traits.hpp>
#include <opencv2/core/types.hpp>
#include <opencv2/core/utility.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
static inline void show1(ev::EventHistogram3b &evhist) {
cv::resize(evhist.render(), resized, ev::Size(), 2, 2, cv::INTER_NEAREST);
cv::imshow("example-davis: dvs", resized);
cv::waitKey(1);
}
static inline void show2(cv::Mat &img) {
cv::Mat resized;
cv::resize(img, resized, ev::Size(), 2, 2, cv::INTER_NEAREST);
cv::imshow("example-davis: aps", resized);
cv::waitKey(1);
}
int main(int /*argc*/, const char * /*argv*/[]) {
ev::Davis camera;
camera.setRoi(cv::Rect(20, 20, 250, 200));
std::cout << camera.getRoi() << '\n';
camera.enableDvs(true);
camera.enableAps(true);
camera.enableImu(false);
camera.setContainerInterval(33333U); // 30Hz
camera.setContainerSize(0); // No limit
ev::Vector events;
ev::Imu imu;
camera.start();
while(true) {
events.clear();
evhist.clear();
camera.getData(events, img, imu);
std::cout << events.size() << ", " << !img.empty() << ", " << !imu.empty() << '\n';
if(!events.empty()) {
evhist.insert(events);
show1(evhist);
}
if(!img.empty()) {
show2(img);
}
if(!imu.empty()) {
std::cout << imu << '\n';
}
}
return 0;
}
Abstract camera device driver.
cv::Rect_< uint16_t > getRoi() const
Get current ROI.
Definition abstract-camera.cpp:37
void setContainerInterval(const uint32_t usec)
Set the maximum time interval between subsequent containers.
Definition abstract-camera.cpp:90
void setContainerSize(const uint32_t n)
Set the maximum number of events a container may hold before it is delivered. The limit applies to ea...
Definition abstract-camera.cpp:101
bool getData(Vector &events)
Get DVS data.
Definition abstract-camera.cpp:139
This class extends AbstractCamera to operate with DAVIS event cameras. DAVIS cameras offer events (DV...
Definition davis.hpp:31
void enableDvs(bool state)
Enable DVS.
Definition davis.cpp:171
void enableAps(bool state)
Enable APS.
Definition davis.cpp:175
void start() override
Initialize the DAVIS camera. This function sets up the DAVIS camera for operation....
Definition davis.cpp:53
cv::Size getSensorSize() const override
Get device sensor size.
Definition davis.cpp:79
void enableImu(bool state)
Enable IMU.
Definition davis.cpp:221
bool setRoi(const cv::Rect_< uint16_t > &roi) override
Set current ROI. Events outside the ROI are not considered. Images are cropped according to the ROI.
Definition davis.cpp:122
cv::Mat & render()
Render event histogram matrix.
This class extends cv::Mat to include timestamp.
Definition abstract-camera.hpp:48
Camera device driver for DAVIS cameras.
2D histogram of events.
EventHistogram_< cv::Vec3b > EventHistogram3b
Definition event-histogram.hpp:78
This struct is used to store IMU data from a DAVIS event camera.
Definition abstract-camera.hpp:105
Basic event-based vision structures based on OpenCV components.
Size2 Size
Definition types.hpp:317
Vector container for basic event structures.
Vectori Vector
Definition vector.hpp:31