Analytics
- class AnalyticsPacket(type, tag, qos, results)
Attributes added to all analytics packets loaded from file.
- class CustomEvent(results, tag=None, qos=0)
A custom event published by edgeiq.publish_analytics().
- Parameters:
results (
Any
) – The custom event data parsed from the analytics file.
- load_analytics_results(filepath, packet_types=None, num_logs=None)
Load results from file published by the alwaysAI Analytics Service.
Typical usage:
deserialized_results = edgeiq.load_analytics_results('logs/analytics.txt') left_camera_results = [result for result in deserialized_results if 'left' in result.tag] right_camera_results = [result for result in deserialized_results if 'right' in result.tag]
- Parameters:
- Return type:
Sequence
[Union
[AnalyticsPacket
,CustomEvent
,TrackingResults
,ClassificationResults
,HumanPoseResult
,ObjectDetectionResults
,ReIdentificationResults
,InstanceSegmentationResults
,BarcodeDetectionResults
,QRCodeDetectionResults
,OccurrenceEvent
,ValueEvent
,StartTimedEvent
,EndTimedEvent
]]- Returns:
A list of the deserialized results. Each deserialized result will include a tag property.
- parse_analytics_packet(packet_str)
Takes in an analytics packet as input and parses it to extract relevant information. The analytics packet is expected to be in JSON format. The function then returns the extracted result object.
Typical Usage:
packet = '{"type": "ObjectDetectionResult", "results": {...}}' result = parse_analytics_packet(packet)
- publish_analytics(results, tag=None, **kwargs)
Publish data to the alwaysAI Analytics Service
Example usage:
try: edgeiq.publish_analytics(results, tag='custom_tag') except edgeiq.PublishError as e: # Retry publish except edgeiq.ConnectionError as e: # Save state and exit app to reconnect
- Parameters:
- Raises:
ConnectionBlockedError
when using connection to the alwaysAI Device Agent and resources are at capacity,- Raises:
PacketRateError
when publish rate exceeds current limit,- Raises:
PacketSizeError
when packet size exceeds current limit. Packet publish size and rate limits will be provided in the error message.
- write_object_detection_results_to_analytics_file(output_file_path, results, tag=None)
Write results to an analytics file at a custom path.
This is useful for writing to analytics files in a scripting environment, as opposed to an application environment. This function doesn’t require alwaysai.app.json.
- Parameters:
output_file_path (
str
) – Full path to the analytics file to write to. The file may not exist, but the directory must exist.results (
ObjectDetectionResults
) – TheObjectDetectionResults
to write to the analytics file.
- Return type:
- write_tracking_results_to_analytics_file(output_file_path, results, tag=None)
Write tracking results to an analytics file at a custom path.
This is useful for writing to analytics files in a scripting environment, as opposed to an application environment. This function doesn’t require alwaysai.app.json.
- Parameters:
output_file_path (
str
) – Full path to the analytics file to write to. The file may not exist, but the directory must exist.results (
TrackingResults
) – TheTrackingResults
to write to the analytics file.
- Return type: