OpenEV
Extending OpenCV to event-based vision
Loading...
Searching...
No Matches
readers_test_utils.hpp
1#pragma once
2
6
7static bool tryPull(ev::AbstractReader_ &reader, ev::Event &e) {
8 ev::ConcurrentQueue *q = &reader.events();
9 if(q->empty()) {
10 q = &reader.events(1);
11 }
12 if(q->empty()) {
13 return false;
14 }
15 e = q->front();
16 q->pop();
17 return true;
18}
19
20static ev::Vector drainAll(ev::AbstractReader_ &reader) {
21 ev::Vector v;
22 ev::Event e;
23 while(tryPull(reader, e)) {
24 v.push_back(e);
25 }
26 return v;
27}
Abstract base class for event readers.
This is an auxiliary class. This class cannot be instanced.
Definition abstract-reader.hpp:28
ConcurrentQueue & events(const std::size_t n=0)
Read a given number of events, add them to the queue, and return it.
Definition abstract-reader.hpp:46
bool empty() const
Check if the queue holds no events.
Definition concurrent_queue.hpp:57
Queue container for basic event structures, safe between a thread that pushes and a thread that pops.
ConcurrentQueuei ConcurrentQueue
Definition concurrent_queue.hpp:93
Eventi Event
Definition types.hpp:262
Vector container for basic event structures.
Vectori Vector
Definition vector.hpp:31