engagementanalytics.utils package
Submodules
engagementanalytics.utils.engagementhelper module
This module provides the EngagementHelper class for determining engagement based on points and directions.
Example usage:
from engagementanalytics.utils.engagementhelper import EngagementHelper
engagement = EngagementHelper()
point = {'x': 1, 'y': 2}
direction = {'x': 0.5, 'y': 0.5}
roi = [{'x': 3, 'y': 4}]
threshold = 0
is_engaged = engagement.is_engaged(point, direction, roi, threshold)
- class engagementanalytics.utils.engagementhelper.EngagementHelper
Bases:
object
EngagementHelper class for determining engagement based on points and directions.
- is_engaged(point, direction, roi, threshold=0)
Checks if a point is engaged based on a direction and a region of interest (ROI).
- Parameters:
point (dict) – The starting point with fields ‘x’ and ‘y’.
direction (dict) – The direction vector with fields ‘x’ and ‘y’.
roi (list) – A list of dictionaries representing the region of interest with fields ‘x’,
'y' (z can be ignored)
'z' (and)
threshold (float) – The cosine similarity threshold to determine engagement. it will be
point. (ignored if roi contains more than one)
- Returns:
True if the point is engaged, False otherwise.
- Return type:
bool
engagementanalytics.utils.heatmap module
This module provides the Heatmap class for managing and clustering detection points over time.
- class engagementanalytics.utils.heatmap.Heatmap(window_seconds=5, eps=50, min_samples=3)
Bases:
object
Heatmap class for managing and clustering detection points over time.
It is designed to handle detection points in a video or image space, cluster them using the DBSCAN algorithm, and return hot spots with normalized intensities.
- get()
Clusters the current detections and returns hot spots.
- Returns:
- Each dictionary contains ‘x’, ‘y’, ‘intensity’, and ‘radius’ keys,
representing the cluster center (x, y), the count of detections, and the radius of the cluster in pixels. Intensity is normalized from 0 to 1.
- Return type:
List[dict]
- update(new_detections, current_time=None)
Add new detection points to the heatmap.
- Parameters:
new_detections (list of tuples) – Each tuple is (x, y) in pixel coordinates.
current_time (float) – The current timestamp (defaults to time.time()).