Analytics¶
-
class
CustomEvent
(results)¶ Store the attributes of this result.
- Parameters
results (
Any
) – The custom event data parsed from the analytics file.
-
property
results
¶ The custom event data parsed from the analytics file.
- Return type
Any
-
property
tag
¶ The tag for the custom event.
- Return type
Optional
[Any
]
-
load_analytics_results
(filepath)¶ 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
filepath (
str
) – The full path to the file to load.- Return type
list
- 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": "TRACKING_RESULT", "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
results (JSON-serializable object.) – The results to publish.
tag (
Optional
[Any
]) – Additional information to assist in querying and visualizations.
- 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)¶ 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
None
-
write_tracking_results_to_analytics_file
(output_file_path, results)¶ 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
None