OpenEV
Extending OpenCV to event-based vision
Toggle main menu visibility
Loading...
Searching...
No Matches
array.hpp
Go to the documentation of this file.
1
6
#ifndef OPENEV_CONTAINERS_ARRAY_HPP
7
#define OPENEV_CONTAINERS_ARRAY_HPP
8
9
#include "
openev/core/types.hpp
"
10
#include <array>
11
#include <cstddef>
12
#include <numeric>
13
#include <opencv2/core/types.hpp>
14
15
namespace
ev {
16
constexpr
bool
USING_ARRAY_HPP =
true
;
17
23
template
<
typename
T, std::
size_t
N>
24
class
Array_
:
public
std::array<Event_<T>, N> {
25
using
std::array<
Event_<T>
, N>::array;
26
using
ResultType = TimeType;
27
28
public
:
33
[[nodiscard]]
inline
ResultType
duration
()
const
{
34
return
std::array<ev::Event_<T>, N>::back().t - std::array<ev::Event_<T>, N>::front().t;
35
}
36
41
[[nodiscard]]
inline
ResultType
rate
()
const
{
42
return
std::array<ev::Event_<T>, N>::size() /
duration
();
43
}
44
49
[[nodiscard]]
inline
Event_<ResultType>
mean
()
const
{
50
const
ResultType x = std::accumulate(std::array<
ev::Event_<T>
, N>::begin(), std::array<
ev::Event_<T>
, N>::end(), 0.0, [](ResultType sum,
const
Event_<T>
&e) {
return
sum + e.x; }) / N;
51
const
ResultType y = std::accumulate(std::array<
ev::Event_<T>
, N>::begin(), std::array<
ev::Event_<T>
, N>::end(), 0.0, [](ResultType sum,
const
Event_<T>
&e) {
return
sum + e.y; }) / N;
52
const
ResultType t = std::accumulate(std::array<
ev::Event_<T>
, N>::begin(), std::array<
ev::Event_<T>
, N>::end(), 0.0, [](ResultType sum,
const
Event_<T>
&e) {
return
sum + e.
t
; }) / N;
53
const
ResultType p = std::accumulate(std::array<
ev::Event_<T>
, N>::begin(), std::array<
ev::Event_<T>
, N>::end(), 0.0, [](ResultType sum,
const
Event_<T>
&e) {
return
sum + e.
p
; }) / N;
54
return
{x, y, t, p > 0.5};
55
}
56
61
[[nodiscard]]
inline
cv::Point_<ResultType>
meanPoint
()
const
{
62
const
ResultType x = std::accumulate(std::array<
ev::Event_<T>
, N>::begin(), std::array<
ev::Event_<T>
, N>::end(), 0.0, [](ResultType sum,
const
Event_<T>
&e) {
return
sum + e.x; }) / N;
63
const
ResultType y = std::accumulate(std::array<
ev::Event_<T>
, N>::begin(), std::array<
ev::Event_<T>
, N>::end(), 0.0, [](ResultType sum,
const
Event_<T>
&e) {
return
sum + e.y; }) / N;
64
return
{x, y};
65
}
66
71
[[nodiscard]]
inline
ResultType
meanTime
()
const
{
72
return
std::accumulate(std::array<
ev::Event_<T>
, N>::begin(), std::array<
ev::Event_<T>
, N>::end(), 0.0, [](ResultType sum,
const
Event_<T>
&e) {
return
sum + e.
t
; }) / N;
73
}
74
79
[[nodiscard]]
inline
ResultType
midTime
()
const
{
80
return
0.5 * (std::array<ev::Event_<T>, N>::front().t + std::array<ev::Event_<T>, N>::back().t);
81
}
82
};
83
84
template
<std::
size_t
N>
85
using
Arrayi
=
Array_<int, N>
;
86
template
<std::
size_t
N>
87
using
Arrayl
=
Array_<long, N>
;
88
template
<std::
size_t
N>
89
using
Arrayf
=
Array_<float, N>
;
90
template
<std::
size_t
N>
91
using
Arrayd
=
Array_<double, N>
;
92
template
<std::
size_t
N>
93
using
Array
=
Arrayi<N>
;
94
}
// namespace ev
95
96
#endif
// OPENEV_CONTAINERS_ARRAY_HPP
ev::Arrayl
Array_< long, N > Arrayl
Definition
array.hpp:87
ev::Arrayf
Array_< float, N > Arrayf
Definition
array.hpp:89
ev::Arrayd
Array_< double, N > Arrayd
Definition
array.hpp:91
ev::Array
Arrayi< N > Array
Definition
array.hpp:93
ev::Arrayi
Array_< int, N > Arrayi
Definition
array.hpp:85
ev::Array_
This class extends std::array to implement event arrays. For more information, please refer here.
Definition
array.hpp:24
ev::Array_< int, N >::rate
ResultType rate() const
Definition
array.hpp:41
ev::Array_< int, N >::duration
ResultType duration() const
Definition
array.hpp:33
ev::Array_< int, N >::mean
Event_< ResultType > mean() const
Definition
array.hpp:49
ev::Array_< int, N >::midTime
ResultType midTime() const
Definition
array.hpp:79
ev::Array_< int, N >::meanTime
ResultType meanTime() const
Definition
array.hpp:71
ev::Array_< int, N >::meanPoint
cv::Point_< ResultType > meanPoint() const
Definition
array.hpp:61
ev::Event_
This class extends cv::Point_<T> for event data. For more information, please refer here.
Definition
types.hpp:77
ev::Event_::p
PolarityType p
Definition
types.hpp:80
ev::Event_::t
TimeType t
Definition
types.hpp:79
types.hpp
Basic event-based vision structures based on OpenCV components.
modules
containers
include
openev
containers
array.hpp
Generated by
1.17.0