SDK ML 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

EventBbox()

Default constructor.

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

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

float get_x() const

Gets x position of the bounding box.

Return

X position of the bounding box

float get_y() const

Gets y position of the bounding box.

Return

Y position of the bounding box

float get_width() const

Gets bounding box’s width.

Return

Width of the bounding box

float get_height() const

Gets bounding box’s height.

Return

Height of the bounding box

unsigned int get_class_id() const

Gets bounding box’s class id.

Return

bounding box’s class id

float intersection_area(const EventBbox &bbox2) const

Computes the area recovered by both boxes.

Return

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

Parameters
  • bbox2: Box to be compared with

float intersection_area_over_union(const EventBbox &bbox2) const

Computes the proportion of box overlap.

Return

Percentage of overlap

Parameters
  • bbox2: Box to be compared with

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

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

Reads EventBbox from a buffer.

Return

An unserialized event bounding box

Parameters
  • buf: Memory containing a serialized bounding box

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

Friends

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

Serializes an EventBbox into a stream.

Return

Stream provided as input

Parameters
  • output: Stream

  • e: EventBbox to be serialized