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

DeepSight SDK last detections container class class. More...

Public Member Functions

 LastDetections (std::chrono::milliseconds maxWindowDuration=std::chrono::milliseconds{ 10000 })
 ds::LastDetections constructor. More...
 
 ~LastDetections () noexcept
 ds::LastDetections destructor.
 
 LastDetections (LastDetections &&lastDetections) noexcept
 ds::LastDetections move constructor.
 
LastDetections & operator= (LastDetections &&lastDetections) noexcept
 ds::LastDetections move assignment operator.
 
void newDetections (const std::vector< ds::Person > &people)
 Stores the provided detections as last detections for each person. More...
 
std::vector< ds::Person > getLastDetections (std::chrono::milliseconds windowDuration=std::chrono::milliseconds{ 0 })
 Get the last detection for each person 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 last detections container class class.

The ds::LastDetections class keeps track of the last detection for each ID in a given time window. All detections provided to ds::LastDetections::newDetections calls outside of the window will be discarded.

Constructor & Destructor Documentation

◆ LastDetections()

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

ds::LastDetections constructor.

Parameters
maxWindowDurationThe maximum window of time over which the last detection of each person is kept.

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::LastDetections::clean ( )
noexcept

Discards all detections from the internal state.

◆ getLastDetections()

std::vector< ds::Person > ds::LastDetections::getLastDetections ( std::chrono::milliseconds  windowDuration = std::chrono::milliseconds{ 0 })

Get the last detection for each person in the provided time window.

Parameters
windowDurationThe window of time over which the last detection are returned.
Returns
A vector of people detections.

This function returns the last detection of each person 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::LastDetections::getMaxWindowDuration ( ) const
noexcept

Returns the maximum window duration data will be internaly stored.

Returns
The maximum window duration in milliseconds.

◆ newDetections()

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

Stores the provided detections as last detections for each person.

Parameters
peopleNew detections to keep track of.

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

Example usage:

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

◆ setMaxWindowDuration()

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

Sets the maximum window duration data will be internaly stored.

Parameters
maxWindowDurationThe maximum window duration in milliseconds.
ds::LastDetections::newDetections
void newDetections(const std::vector< ds::Person > &people)
Stores the provided detections as last detections for each person.
ds::LastDetections
DeepSight SDK last detections container class class.
Definition: ds_aggregator.h:72