DeepSight SDK  3.0.0
DeepSight SDK - crowd face analysis
ds_aggregator.h
Go to the documentation of this file.
1 /*
2  * DeepSight face analysis SDK
3  * Copyright (C) 2013-2023 Raydiant Inc. - All Rights Reserved
4  *
5  * This file is subject to the terms and conditions defined in
6  * the 'LICENSE.txt' file, which is part of this source code package.
7  *
8  */
9 
10 #ifndef DS_AGGREGATOR_H
11 #define DS_AGGREGATOR_H
12 
13 #include "ds_exports.h"
14 #include "ds_person.h"
15 
16 #include <memory>
17 #include <vector>
18 #include <chrono>
19 
20 namespace ds
21 {
23 {
24 public:
25  Aggregator();
26  ~Aggregator() noexcept;
27 
28  Aggregator( Aggregator && aggregator ) noexcept;
29  Aggregator & operator=( Aggregator && aggregator ) noexcept;
30 
31  static std::vector<ds::AggregatedPerson> aggregateOffline( const std::vector<ds::Person> & people );
32 
33  void newDetections( const std::vector<ds::Person> & people );
34 
35  std::vector<ds::AggregatedPerson> getFinalizedAggregations( bool clean = true );
36  std::vector<ds::AggregatedPerson> getOngoingAggregations() const;
37  std::vector<ds::AggregatedPerson> getAllAggregations() const;
38 
39  void cleanFinalizedAggregations() noexcept;
40  void cleanAll() noexcept;
41 
42 private:
43  class AggregatorImpl;
44  std::unique_ptr<AggregatorImpl> mAggregatorImpl;
45 };
46 
47 
49 {
50 public:
51  SlidingWindowAggregator( std::chrono::milliseconds maxWindowDuration = std::chrono::milliseconds{ 10000 } );
52  ~SlidingWindowAggregator() noexcept;
53 
54  SlidingWindowAggregator( SlidingWindowAggregator && slidingWindowAggregator ) noexcept;
55  SlidingWindowAggregator & operator=( SlidingWindowAggregator && slidingWindowAggregator ) noexcept;
56 
57  void newDetections( const std::vector<ds::Person> & people );
58 
59  std::vector<ds::AggregatedPerson> getAggregations( std::chrono::milliseconds windowDuration = std::chrono::milliseconds{ 0 } );
60 
61  std::chrono::milliseconds getMaxWindowDuration() const noexcept;
62  void setMaxWindowDuration( std::chrono::milliseconds maxWindowDuration ) noexcept;
63 
64  void clean() noexcept;
65 
66 private:
67  class SlidingWindowAggregatorImpl;
68  std::unique_ptr<SlidingWindowAggregatorImpl> mSlidingWindowAggregatorImpl;
69 };
70 
71 
73 {
74 public:
75  LastDetections( std::chrono::milliseconds maxWindowDuration = std::chrono::milliseconds{ 10000 } );
76  ~LastDetections() noexcept;
77 
78  LastDetections( LastDetections && lastDetections ) noexcept;
79  LastDetections & operator=( LastDetections && lastDetections ) noexcept;
80 
81  void newDetections( const std::vector<ds::Person> & people );
82 
83  std::vector<ds::Person> getLastDetections( std::chrono::milliseconds windowDuration = std::chrono::milliseconds{ 0 } );
84 
85  std::chrono::milliseconds getMaxWindowDuration() const noexcept;
86  void setMaxWindowDuration( std::chrono::milliseconds maxWindowDuration ) noexcept;
87 
88  void clean() noexcept;
89 
90 private:
91  class LastDetectionsImpl;
92  std::unique_ptr<LastDetectionsImpl> mLastDetectionsImpl;
93 };
94 
95 
97 {
98 public:
99  BodyAggregator();
100  ~BodyAggregator() noexcept;
101 
102  BodyAggregator( BodyAggregator && bodyAggregator ) noexcept;
103  BodyAggregator & operator=( BodyAggregator && bodyAggregator ) noexcept;
104 
105  static std::vector<ds::AggregatedBody> aggregateOffline( const std::vector<ds::Body> & bodies );
106 
107  void newDetections( const std::vector<ds::Body> & bodies );
108 
109  std::vector<ds::AggregatedBody> getFinalizedAggregations( bool clean = true );
110  std::vector<ds::AggregatedBody> getOngoingAggregations() const;
111  std::vector<ds::AggregatedBody> getAllAggregations() const;
112 
113  void cleanFinalizedAggregations() noexcept;
114  void cleanAll() noexcept;
115 
116 private:
117  class BodyAggregatorImpl;
118  std::unique_ptr<BodyAggregatorImpl> mBodyAggregatorImpl;
119 };
120 
121 
123 {
124 public:
125  SlidingWindowBodyAggregator( std::chrono::milliseconds maxWindowDuration = std::chrono::milliseconds{ 10000 } );
126  ~SlidingWindowBodyAggregator() noexcept;
127 
128  SlidingWindowBodyAggregator( SlidingWindowBodyAggregator && slidingWindowBodyAggregator ) noexcept;
129  SlidingWindowBodyAggregator & operator=( SlidingWindowBodyAggregator && slidingWindowBodyAggregator ) noexcept;
130 
131  void newDetections( const std::vector<ds::Body> & body );
132 
133  std::vector<ds::AggregatedBody> getAggregations( std::chrono::milliseconds windowDuration = std::chrono::milliseconds{ 0 } );
134 
135  std::chrono::milliseconds getMaxWindowDuration() const noexcept;
136  void setMaxWindowDuration( std::chrono::milliseconds maxWindowDuration ) noexcept;
137 
138  void clean() noexcept;
139 
140 private:
141  class SlidingWindowBodyAggregatorImpl;
142  std::unique_ptr<SlidingWindowBodyAggregatorImpl> mSlidingWindowBodyAggregatorImpl;
143 };
144 
145 
147 {
148 public:
149  LastBodyDetections( std::chrono::milliseconds maxWindowDuration = std::chrono::milliseconds{ 10000 } );
150  ~LastBodyDetections() noexcept;
151 
152  LastBodyDetections( LastBodyDetections && lastBodyDetections ) noexcept;
153  LastBodyDetections & operator=( LastBodyDetections && lastBodyDetections ) noexcept;
154 
155  void newDetections( const std::vector<ds::Body> & bodies );
156 
157  std::vector<ds::Body> getLastDetections( std::chrono::milliseconds windowDuration = std::chrono::milliseconds{ 0 } );
158 
159  std::chrono::milliseconds getMaxWindowDuration() const noexcept;
160  void setMaxWindowDuration( std::chrono::milliseconds maxWindowDuration ) noexcept;
161 
162  void clean() noexcept;
163 
164 private:
165  class LastBodyDetectionsImpl;
166  std::unique_ptr<LastBodyDetectionsImpl> mLastBodyDetectionsImpl;
167 };
168 } /* namespace ds */
169 
170 #endif /* DS_AGGREGATOR_H */
ds::Aggregator
DeepSight SDK aggregator class.
Definition: ds_aggregator.h:22
DS_API
#define DS_API
Controls the importing of the SDK symbols.
ds::SlidingWindowBodyAggregator
DeepSight SDK sliding time window aggregator class.
Definition: ds_aggregator.h:122
ds::BodyAggregator
DeepSight SDK body aggregator class.
Definition: ds_aggregator.h:96
ds::LastBodyDetections
DeepSight SDK last body detections container class class.
Definition: ds_aggregator.h:146
ds::LastDetections
DeepSight SDK last detections container class class.
Definition: ds_aggregator.h:72
ds_person.h
ds::SlidingWindowAggregator
DeepSight SDK sliding time window aggregator class.
Definition: ds_aggregator.h:48
ds_exports.h