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

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

Public Member Functions

 LastBodyDetections (std::chrono::milliseconds maxWindowDuration=std::chrono::milliseconds{ 10000 })
 ds::LastBodyDetections constructor. More...
 
 ~LastBodyDetections () noexcept
 ds::LastBodyDetections destructor.
 
 LastBodyDetections (LastBodyDetections &&lastBodyDetections) noexcept
 ds::LastBodyDetections move constructor.
 
LastBodyDetections & operator= (LastBodyDetections &&lastBodyDetections) noexcept
 ds::LastBodyDetections move assignment operator.
 
void newDetections (const std::vector< ds::Body > &bodies)
 Stores the provided detections as last detections for each body. More...
 
std::vector< ds::Body > getLastDetections (std::chrono::milliseconds windowDuration=std::chrono::milliseconds{ 0 })
 Get the last detection for each body 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.
 

Detailed Description

DeepSight SDK last body detections container class class.

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

Constructor & Destructor Documentation

◆ LastBodyDetections()

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

ds::LastBodyDetections constructor.

Parameters
maxWindowDurationThe maximum window of time over which the last detection of each body 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

◆ getLastDetections()

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

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

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

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

◆ getMaxWindowDuration()

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

Returns the maximum window duration data will be internaly stored.

Returns
The maximum window duration in milliseconds.

◆ newDetections()

void ds::LastBodyDetections::newDetections ( const std::vector< ds::Body > &  bodies)

Stores the provided detections as last detections for each body.

Parameters
bodiesNew body detections to keep track of.

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

Example usage:

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

◆ setMaxWindowDuration()

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

Sets the maximum window duration data will be internaly stored.

Parameters
maxWindowDurationThe maximum window duration in milliseconds.
ds::LastBodyDetections
DeepSight SDK last body detections container class class.
Definition: ds_aggregator.h:146
ds::LastBodyDetections::newDetections
void newDetections(const std::vector< ds::Body > &bodies)
Stores the provided detections as last detections for each body.