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

This is an example of how to use the PointCloud_<T> class.

#include <opencv2/core/mat.inl.hpp>
#include <opencv2/core/traits.hpp>
#include <random>
int main(int /*argc*/, const char * /*argv*/[]) {
ev::PointCloud pointcloud;
int row = 0;
int col = 0;
int direction = 0;
int offset = 0;
double t = 0;
// Initialize random number generator
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<int> dist(0, 1);
while(offset < 30) {
t += 0.1;
pointcloud.insert(ev::Event(col, row, t, static_cast<bool>(dist(gen)) ? ev::POSITIVE : ev::NEGATIVE));
switch(direction) {
case 0:
col++;
if(col >= 50 - offset) {
direction++;
}
break;
case 1:
row++;
if(row >= 50 - offset) {
direction++;
}
break;
case 2:
col--;
if(col <= offset) {
direction++;
offset++;
}
break;
case 3:
row--;
if(row <= offset) {
direction = 0;
}
default:
break;
}
}
pointcloud.visualize(0, 0.4);
return 0;
}
bool insert(const Event_< E > &e)
Insert one event in the representation.
void visualize(const int t, const double time_scale=1.0, const double axis_size=1.0, const double point_size=2.0)
Visualize point cloud.
Point cloud of events.
PointCloud1 PointCloud
Definition point-cloud.hpp:93
Basic event-based vision structures based on OpenCV components.
constexpr bool POSITIVE
Definition types.hpp:27
constexpr bool NEGATIVE
Definition types.hpp:28
Eventi Event
Definition types.hpp:244