SDK Core Events

struct Metavision::EventBbox

Class representing a spatio-temporal bounding-box event.

The timestamp of the event (i.e. member variable ‘t’) is by convention the detection timestamp. Convention about the spatial position is that points with u in [x, x + w[ and v in [y, y + h[ are inside the bounding-box and everything else is outside.

Public Functions

inline EventBbox()

Default constructor.

inline EventBbox(timestamp time, float x, float y, float w, float h, unsigned int class_id, unsigned int track_id, float class_confidence)

Constructs a Event Bounding box.

Parameters
  • time – Timestamp of last detection

  • x – Column index

  • y – Row index

  • w – Bounding box’s width

  • h – Bounding box’s height

  • class_id – Class identifier

  • track_id – Track identification number

  • class_confidence – Detection confidence

inline void write_event(void *buf, timestamp origin) const

Writes EventBbox in buffer.

Parameters
  • buf – Memory in which the bounding box will be serialized

  • origin – Reference timestamp cut away from the bounding box timestamp

inline float get_x() const

Gets x position of the bounding box.

Returns

X position of the bounding box

inline float get_y() const

Gets y position of the bounding box.

Returns

Y position of the bounding box

inline float get_width() const

Gets bounding box’s width.

Returns

Width of the bounding box

inline float get_height() const

Gets bounding box’s height.

Returns

Height of the bounding box

inline unsigned int get_class_id() const

Gets bounding box’s class id.

Returns

bounding box’s class id

inline float intersection_area(const EventBbox &bbox2) const

Computes the area recovered by both boxes.

Parameters

bbox2 – Box to be compared with

Returns

The intersection area between current bbox and bbox 2 (in pixel * pixel)

inline float intersection_area_over_union(const EventBbox &bbox2) const

Computes the proportion of box overlap.

Parameters

bbox2 – Box to be compared with

Returns

Percentage of overlap

inline void write_csv_line(std::ostream &output, char sep = ' ') const

Serialize a bounding box in csv format.

Parameters
  • output – Stream in which the csv of the bounding box will be written

  • sep – Character inserted between fields

Public Members

timestamp t

timestamp of the detection

float x

X coordinate of top left corner.

float y

Y coordinate of top left corner.

float w

width of the bounding box

float h

height of the bounding box

unsigned int class_id

Class identifier of detected object.

unsigned int track_id

Track identifier.

float class_confidence

Confidence of the detection.

Public Static Functions

static inline EventBbox read_event(void *buf, const timestamp &delta_ts)

Reads EventBbox from a buffer.

Parameters
  • buf – Memory containing a serialized bounding box

  • delta_ts – Origin timestamp to be added to the serialized timestamp

Returns

An unserialized event bounding box

Friends

inline friend std::ostream &operator<<(std::ostream &output, const EventBbox &e)

Serializes an EventBbox into a stream.

Parameters
  • output – Stream

  • e – EventBbox to be serialized

Returns

Stream provided as input