swarmsort.integration module
Integration utilities for SwarmSort when used within the swarmtracker pipeline.
This module provides compatibility layers and integration helpers that allow SwarmSort to seamlessly work with the full swarmtracker ecosystem while maintaining standalone functionality.
- class swarmsort.integration.AdaptiveSwarmSortTracker(config=None)[source]
Bases:
objectAdaptive wrapper for SwarmSortTracker that automatically handles both standalone and swarmtracker integration modes.
- property config
Access tracker configuration.
- swarmsort.integration.StandaloneSwarmSort
alias of
_StandaloneSwarmSortWrapper
- swarmsort.integration.SwarmSort
alias of
AdaptiveSwarmSortTracker
- swarmsort.integration.convert_any_detection(detection)[source]
Universal detection converter that handles various detection formats.
This function provides a single entry point for converting detections from any format to the SwarmSort StandaloneDetection format. It handles: - SwarmSort Detection objects (passthrough) - SwarmTracker detection objects - Objects with position/bbox and confidence attributes - Dictionaries with ‘position’/’bbox’ and ‘confidence’ keys
- Parameters:
detection – Detection in any supported format
- Returns:
Converted detection compatible with SwarmSort
- Return type:
StandaloneDetection
- Raises:
ValueError – If position cannot be extracted from the detection
Example
>>> # Works with dict >>> det = convert_any_detection({'position': [100, 200], 'confidence': 0.9}) >>> # Works with objects >>> det = convert_any_detection(some_detector_output)
- swarmsort.integration.convert_swarmtracker_detection(swarmtracker_det)[source]
Convert a swarmtracker Detection to standalone Detection.
- Parameters:
swarmtracker_det – Detection object from swarmtracker
- Returns:
Converted detection
- Return type:
StandaloneDetection
- swarmsort.integration.convert_to_swarmtracker_tracked_object(standalone_obj)[source]
Convert a standalone TrackedObject to swarmtracker format.
- Parameters:
standalone_obj (
TrackedObject) – StandaloneTrackedObject instance- Returns:
Swarmtracker compatible tracked object
- swarmsort.integration.create_adaptive_detection_converter()[source]
Create a detection converter that automatically handles both formats.
- Returns:
Callable that converts any detection to standalone format
- swarmsort.integration.create_adaptive_tracker_output_converter()[source]
Create an output converter that returns the appropriate format.
- Returns:
Callable that converts tracked objects to the expected format
- swarmsort.integration.create_tracker(config=None, force_standalone=False)[source]
Factory function to create the appropriate tracker instance.
- Parameters:
config – Configuration (SwarmSortConfig, dict, or path to YAML file)
force_standalone – If True, always create standalone tracker
- Returns:
Tracker instance (adaptive or standalone)
- swarmsort.integration.get_swarmtracker_detection_class()[source]
Get the swarmtracker Detection class if available.
- swarmsort.integration.get_swarmtracker_tracked_object_class()[source]
Get the swarmtracker TrackedObject class if available.
- swarmsort.integration.is_within_swarmtracker()[source]
Detect if SwarmSort is being used within the swarmtracker pipeline.
- Returns:
True if running within swarmtracker, False if standalone
- Return type: