DeepSight SDK  3.0.0
DeepSight SDK - crowd face analysis
ds::SlidingWindowAggregator Class Reference

DeepSight SDK sliding time window aggregator class. More...

Public Member Functions

 SlidingWindowAggregator (std::chrono::milliseconds maxWindowDuration=std::chrono::milliseconds{ 10000 })
 ds::SlidingWindowAggregator constructor. More...
 
 ~SlidingWindowAggregator () noexcept
 ds::SlidingWindowAggregator destructor.
 
 SlidingWindowAggregator (SlidingWindowAggregator &&slidingWindowAggregator) noexcept
 ds::SlidingWindowAggregator move constructor.
 
SlidingWindowAggregator & operator= (SlidingWindowAggregator &&slidingWindowAggregator) noexcept
 ds::SlidingWindowAggregator move assignment operator.
 
void newDetections (const std::vector< ds::Person > &people)
 Adds new detections to the current state of aggregations. More...
 
std::vector< ds::AggregatedPerson > getAggregations (std::chrono::milliseconds windowDuration=std::chrono::milliseconds{ 0 })
 Get people aggregations in the provided time window. More...
 
std::chrono::milliseconds getMaxWindowDuration () const noexcept
 Returns the maximum window duration data will be internaly stored. More...
 
void setMaxWindowDuration (std::chrono::milliseconds maxWindowDuration) noexcept
 Sets the maximum window duration data will be internaly stored. More...
 
void clean () noexcept
 Discards all detections from the internal state. More...
 

Detailed Description

DeepSight SDK sliding time window aggregator class.

The ds::SlidingWindowAggregator class aggregates all information retrieved for each unique person during a window of time. It is therefore possible to know what happened in the last time window (eg. in the last 10 seconds) at any given time, without having to preemptively initialize a ds::Aggregator. All detections provided to ds::SlidingWindowAggregator::newDetections calls outside of the window will be discarded.

In order to implement a sliding window aggregation strategy, all the detections within the time window need to be stored internally. Therefore the larger the time window, the larger the memory requirements.

Constructor & Destructor Documentation

◆ SlidingWindowAggregator()

ds::SlidingWindowAggregator::SlidingWindowAggregator ( std::chrono::milliseconds  maxWindowDuration = std::chrono::milliseconds{ 10000 })

ds::SlidingWindowAggregator constructor.

Parameters
maxWindowDurationThe maximum window of time over which the aggregation will be performed.

The maximum time window is defined as the time between (std::chrono::system_clock::now() - maxWindowDuration) and (std::chrono::system_clock::now())

Member Function Documentation

◆ clean()

void ds::SlidingWindowAggregator::clean ( )
noexcept

Discards all detections from the internal state.

◆ getAggregations()

std::vector< ds::AggregatedPerson > ds::SlidingWindowAggregator::getAggregations ( std::chrono::milliseconds  windowDuration = std::chrono::milliseconds{ 0 })

Get people aggregations in the provided time window.

Parameters
windowDurationThe window of time over which the aggregation will be performed.
Returns
A vector of aggregated people.

This function aggregates all people detected in the last windowDuration milliseconds. The windowDuration parameter cannot be larger than the maxWindowDuration provided during construction. All detections older than (std::chrono::system_clock::now() - maxWindowDuration) will be discarded. A person with a detection duration shorter that 1 second is considered a false positive and therefore not returned.

◆ getMaxWindowDuration()

std::chrono::milliseconds ds::SlidingWindowAggregator::getMaxWindowDuration ( ) const
noexcept

Returns the maximum window duration data will be internaly stored.

Returns
The maximum window duration in milliseconds.

◆ newDetections()

void ds::SlidingWindowAggregator::newDetections ( const std::vector< ds::Person > &  people)

Adds new detections to the current state of aggregations.

Parameters
peopleNew detections to aggregate.

This function stores the new detections in the internal buffer. All detections outside the time window will be discarded.

Example usage:

ds::SlidingWindowAggregator windowAggregator( std::chrono::milliseconds{ 5000 } );
while( true )
{
cap >> frame;
if( frame.empty() )
break;
// Analyze frame
std::vector<ds::Person> people = ds.analyze( frame );
// Add new detections to the aggregation window
windowAggregator.newDetections( people );
}
// Count how many unique people were detected during the last 5 seconds of the video
std::cout << windowAggregator.getAggregations().size() << std::endl;

◆ setMaxWindowDuration()

void ds::SlidingWindowAggregator::setMaxWindowDuration ( std::chrono::milliseconds  maxWindowDuration)
noexcept

Sets the maximum window duration data will be internaly stored.

Parameters
maxWindowDurationThe maximum window duration in milliseconds.
ds::SlidingWindowAggregator::newDetections
void newDetections(const std::vector< ds::Person > &people)
Adds new detections to the current state of aggregations.
ds::SlidingWindowAggregator
DeepSight SDK sliding time window aggregator class.
Definition: ds_aggregator.h:48