Analysis Results

The BrainFrame server organizes detected objects by the zones that those detections were found in. Detections for a zone, alongside information on that zone’s state and any active alerts for that zone, are contained in ZoneStatus objects. For every video frame where analysis is performed, a ZoneStatus object will be created for every zone in that frame.

API Methods

BrainFrameAPI.get_latest_zone_statuses(timeout=30) → Dict[int, Dict[str, brainframe.api.bf_codecs.zone_codecs.ZoneStatus]]

This method gets all of the latest processed zone statuses for every zone and for every stream.

All active streams will have a key in the output dict.

Parameters

timeout – The timeout to use for this request

Returns

A dict whose keys are stream IDs and whose value is another dict. This nested dict’s keys are zone names and their value is the ZoneStatus for that zone.

BrainFrameAPI.get_zone_status_stream(timeout=None) → Generator[Dict[int, Dict[str, brainframe.api.bf_codecs.zone_codecs.ZoneStatus]], None, None]

Streams ZoneStatus results from the server as they are produced.

All active streams will have a key in the output dict.

Parameters

timeout – The timeout to use for this request

Returns

A generator that outputs dicts whose keys are stream IDs and whose value is another dict. This nested dict’s keys are zone names and their value is the ZoneStatus for that zone.

Data Structures

class Attribute(category: str, value: str)

This holds an attribute of a detection. These should _not_ be made on the client side

category: str

The category of attribute being described

value: str

The value for this attribute category

class Detection(class_name: str, coords: List[List[int]], children: List[Detection], attributes: Dict[str, str], with_identity: Optional[brainframe.api.bf_codecs.identity_codecs.Identity], extra_data: Dict[str, Any], track_id: Optional[uuid.UUID])

An object detected in a video frame. Detections can have attributes attached to them that provide more information about the object as well as other metadata like a unique tracking ID.

attributes: Dict[str, str]

A dict whose key is an attribute name and whose value is the value of that attribute. For example, a car detection may have an attribute whose key is ‘type’ and whose value is ‘sedan’.

property center

Return the center of the detections coordinates

class_name: str

The class of object that was detected, like ‘person’ or ‘car’

coords: List[List[int]]

The coordinates, in pixels, of the detection in the frame

extra_data: Dict[str, Any]

Any additional metadata describing this object

track_id: Optional[uuid.UUID]

If not None, this is a unique tracking ID for the object. This ID can be compared to detections from other frames to track the movement of an object over time.

with_identity: Optional[Identity]

If not None, this is the identity that this detection was recognized as.

class ZoneStatus(zone: brainframe.api.bf_codecs.zone_codecs.Zone, tstamp: float, total_entered: dict, total_exited: dict, within: List[brainframe.api.bf_codecs.detection_codecs.Detection], entering: List[brainframe.api.bf_codecs.detection_codecs.Detection], exiting: List[brainframe.api.bf_codecs.detection_codecs.Detection], alerts: List[brainframe.api.bf_codecs.alarm_codecs.Alert])

The current status of everything going on inside a zone.

alerts: List[Alert]

A list of all active alerts for the zone at this frame

property detection_within_counts

The current count of each class type detected in the video.

Returns

A dict whose keys are class names and whose values are the count for that class name

entering: List[Detection]

A list of all detections that entered the zone this frame

exiting: List[Detection]

A list of all detections that have exited the zone this frame

total_entered: dict

A dict of key-value pairs indicating how many objects have exited the zone. The key is the class name, and the value is the count.

total_exited: dict

A set of key-value pairs indicating how many objects have exited the zone. The key is the object type, and the value is the count.

tstamp: float

The time at which this ZoneStatus was created as a Unix timestamp in seconds

within: List[Detection]

A list of all detections within the zone

zone: Zone

The zone that this status pertains to