Functions
filter_by_confidence
- Filter detections by minimum confidence score threshold.filter_by_class_id
- Filter detections by class identifier(s).remap_class_ids
- Remap class IDs to consolidate or standardize classification labels.filter_by_size
- Filter detections by bounding box area constraints.filter_by_dimensions
- Filter detections by individual width and height constraints.filter_by_aspect_ratio
- Filter detections by bounding box aspect ratio (width/height).filter_by_zones
- Filter detections based on zone intersection status.filter_by_position
- Filter detections by their position within the frame.filter_by_relative_size
- Filter detections by size relative to total frame area.filter_by_tracking_duration
- Filter detections by their tracking duration.filter_by_first_seen_time
- Filter detections by when they were first observed.filter_tracked_objects
- Filter detections based on tracking status.remove_duplicates
- Remove duplicate or highly overlapping detections using Non-Maximum Suppression.filter_overlapping
- Filter detections that significantly overlap with other detections.
filter_by_confidence
Filter detections by minimum confidence score threshold. Applies confidence-based filtering to remove low-confidence detections that may represent false positives or uncertain predictions. Essential preprocessing step for improving detection quality and reducing noise in downstream analysis.Function Signature
Parameters
Minimum confidence score (inclusive). Range: [0.0, 1.0]. Detections with confidence >= threshold are retained. Higher values are more restrictive.
Returns
New Detections object containing only high-confidence detections. Preserves all detection attributes including tracking data.
Example
Example
filter_by_class_id
Filter detections by class identifier(s). Enables class-specific filtering to focus analysis on particular object types. Supports both single class selection and multi-class filtering with flexible ID format handling for different model outputs and naming conventions.Function Signature
Parameters
Single class ID or list of class IDs to include. Accepts both numeric IDs (e.g., COCO indices) and string class names. Mixed types are supported in lists.
Returns
New Detections object containing only detections with matching class IDs. Preserves all detection attributes and metadata.
Example
Example
remap_class_ids
Remap class IDs to consolidate or standardize classification labels. Creates new Detection objects with modified class IDs while preserving all other detection attributes. Useful for consolidating similar classes or standardizing class schemas across different models.Function Signature
Parameters
Source class ID(s) to remap. Single ID or list of IDs.
Target class ID to map to.
Returns
New Detections object with remapped class IDs and cleared class names.
Example
Example
filter_by_size
Filter detections by bounding box area constraints.Function Signature
Parameters
Minimum bounding box area in pixels (inclusive). If None, no minimum constraint is applied.
Maximum bounding box area in pixels (inclusive). If None, no maximum constraint is applied.
Returns
New Detections object containing only detections within size range.
Example
Example
filter_by_dimensions
Filter detections by individual width and height constraints. Provides fine-grained control over detection dimensions, useful for filtering objects based on expected physical dimensions or removing artifacts.Function Signature
Parameters
Minimum bounding box width in pixels (inclusive).
Maximum bounding box width in pixels (inclusive).
Minimum bounding box height in pixels (inclusive).
Maximum bounding box height in pixels (inclusive).
Returns
New Detections object containing only detections within dimension constraints.
Example
Example
filter_by_aspect_ratio
Filter detections by bounding box aspect ratio (width/height). Useful for filtering objects based on their shape characteristics, such as identifying square objects, wide banners, or tall structures.Function Signature
Parameters
Minimum aspect ratio (width/height) (inclusive). Values > 1.0 favor wide objects.
Maximum aspect ratio (width/height) (inclusive). Values < 1.0 favor tall objects.
Returns
New Detections object containing only detections within aspect ratio range.
Example
Example
filter_by_zones
Filter detections based on zone intersection status. Enables spatial filtering by including or excluding detections that intersect with specified zones. Requires prior zone assignment via update_zones().Function Signature
Parameters
Single zone ID or list of zone IDs to filter by. Supports both string names and numeric IDs.
If True, exclude detections in specified zones. If False, include only detections in specified zones. Default is False.
Returns
New Detections object with zone-based filtering applied.
Example
Example
filter_by_position
Filter detections by their position within the frame. Enables spatial filtering based on detection center position relative to frame regions. Useful for focusing on specific areas of interest or excluding edge artifacts.Function Signature
Parameters
Target region to filter by. Options: “center”, “edge”, “top”, “bottom”, “left”, “right”, “corners”.
Margin as percentage of frame size. Range: [0.0, 0.5]. Default is 0.1 (10% margin).
Frame width in pixels. Required for filtering.
Frame height in pixels. Required for filtering.
Returns
New Detections object containing only detections in specified region.
Example
Example
filter_by_relative_size
Filter detections by size relative to total frame area. Provides scale-invariant filtering based on detection size as percentage of total frame area. More robust than absolute size filtering across different resolution inputs.Function Signature
Parameters
Minimum size as percentage of frame area. Range: [0.0, 1.0]. If None, no minimum constraint.
Maximum size as percentage of frame area. Range: [0.0, 1.0]. If None, no maximum constraint.
Frame width in pixels. Required for calculation.
Frame height in pixels. Required for calculation.
Returns
New Detections object containing only detections within relative size range.
Example
Example
filter_by_tracking_duration
Filter detections by their tracking duration.Function Signature
Parameters
Minimum tracking duration in seconds (inclusive). If None, no minimum constraint is applied.
Maximum tracking duration in seconds (inclusive). If None, no maximum constraint is applied.
Returns
New Detections object containing only detections within duration range.
Example
Example
filter_by_first_seen_time
Filter detections by when they were first observed.Function Signature
Parameters
Earliest first seen time (inclusive). Time units depend on tracking implementation (frames, seconds, timestamps).
Latest first seen time (inclusive).
Returns
New Detections object containing only detections first seen within time range.
Example
Example
filter_tracked_objects
Filter detections based on tracking status.Function Signature
Parameters
If True, keep only objects with tracker IDs. If False, keep only objects without tracker IDs. Default is True.
Returns
New Detections object filtered by tracking status.
Example
Example
remove_duplicates
Remove duplicate or highly overlapping detections using Non-Maximum Suppression. Identifies groups of overlapping detections and keeps only one detection per group based on the specified strategy. Essential for cleaning up multi-model outputs or removing redundant detections.Function Signature
Parameters
IoU threshold for considering detections as duplicates. Range: [0.0, 1.0]. Higher values are more restrictive. Default is 0.8.
Strategy for selecting which detection to keep from each group. Options: ‘first’, ‘last’, ‘highest_confidence’. Default is ‘first’.
Returns
New Detections object with duplicate detections removed.
Example
Example
filter_overlapping
Filter detections that significantly overlap with other detections. Useful for finding co-occurring objects, validating detection consistency, or identifying regions with multiple overlapping predictions.Function Signature
Parameters
Minimum IoU overlap required to consider detections as overlapping. Range: [0.0, 1.0]. Default is 0.5.
Optional list of class IDs to check overlap against. If None, checks overlap with all other detections.
Returns
New Detections object containing only detections that overlap sufficiently with other detections.
Example
Example