bbox
bbox.h File Reference

A class representing a bbox session. More...

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
Include dependency graph for bbox.h:

Go to the source code of this file.

Functions

Constructors and Destructors
bbox_t * bbox_new (size_t n_channels,...)
 Create a new bbox object with global coordinate-space. More...
 
bbox_t * bbox_view_new (bbox_channel_t view)
 Create a new bbox object with view coordinate-space. More...
 
bool bbox_destroy (bbox_t *self)
 Destroy the bbox object. More...
 
Functions
bool bbox_coordinates_scene_normalized (bbox_t *self)
 Switch to scene normalized coordinate space [Default]. More...
 
bool bbox_coordinates_frame_normalized (bbox_t *self)
 Switch to frame normalized coordinate space. More...
 
bool bbox_video_output (bbox_t *self, bool enabled)
 Control drawing on video-output. More...
 
bbox_color_t bbox_color_from_rgb (uint8_t r, uint8_t g, uint8_t b)
 Create a new native color from rgb. More...
 
bbox_color_t bbox_color_from_rgba (uint8_t r, uint8_t g, uint8_t b, uint8_t a)
 Create a new native color from rgba. More...
 
bool bbox_clear (bbox_t *self)
 Clear all existing geometry. More...
 
bool bbox_color (bbox_t *self, bbox_color_t color)
 Apply color to all new geometry. More...
 
bool bbox_style_outline (bbox_t *self)
 Replace existing style with ┏━━━━━┓ for all new rectangles. More...
 
bool bbox_style_corners (bbox_t *self)
 Replace existing style with ┏━   ━┓ for all new rectangles. More...
 
bool bbox_thickness_thin (bbox_t *self)
 Change line-thickness to thin for all new geometry. More...
 
bool bbox_thickness_medium (bbox_t *self)
 Change line-thickness to medium for all new geometry. More...
 
bool bbox_thickness_thick (bbox_t *self)
 Change line-thickness to thick for all new geometry. More...
 
bool bbox_rectangle (bbox_t *self, float x1, float y1, float x2, float y2)
 Create a new Rectangle. More...
 
bool bbox_line (bbox_t *self, float x1, float y1, float x2, float y2)
 Create a new Line. More...
 
bool bbox_quad (bbox_t *self, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
 Create a new Quadrilateral. More...
 
bool bbox_move_to (bbox_t *self, float x, float y)
 Move to the specified point. More...
 
bool bbox_line_to (bbox_t *self, float x, float y)
 Adds a point to the current path. More...
 
bool bbox_draw_path (bbox_t *self)
 Draw the current path. More...
 
bool bbox_commit (bbox_t *self, int64_t when_us)
 Draw all queued geometry. More...
 

Detailed Description

A class representing a bbox session.

Copyright (C) 2021, Axis Communications AB, Lund

Function Documentation

◆ bbox_clear()

bool bbox_clear ( bbox_t *  self)

Clear all existing geometry.

Parameters
selfThe bbox object
Returns
Success, check errno on error.

◆ bbox_color()

bool bbox_color ( bbox_t *  self,
bbox_color_t  color 
)

Apply color to all new geometry.

Parameters
selfThe bbox object
colorThe color to apply
Returns
Success, check errno on error.

◆ bbox_color_from_rgb()

bbox_color_t bbox_color_from_rgb ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Create a new native color from rgb.

Parameters
rRed
gGreen
bBlue
Returns
A bbox_color_t in native format

◆ bbox_color_from_rgba()

bbox_color_t bbox_color_from_rgba ( uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  a 
)

Create a new native color from rgba.

Parameters
rRed
gGreen
bBlue
aAlpha
Returns
A bbox_color_t in native format

◆ bbox_commit()

bool bbox_commit ( bbox_t *  self,
int64_t  when_us 
)

Draw all queued geometry.

Parameters
selfThe bbox object
when_usSynchronization time in µs.
Returns
Success, check errno on error.

◆ bbox_coordinates_frame_normalized()

bool bbox_coordinates_frame_normalized ( bbox_t *  self)

Switch to frame normalized coordinate space.

This coordinate system is normalized and aligned with the camera frame, i.e. top-left is [0,0] and bottom-right is [1,1].

Parameters
selfThe bbox object
Returns
Success, check errno on error.

◆ bbox_coordinates_scene_normalized()

bool bbox_coordinates_scene_normalized ( bbox_t *  self)

Switch to scene normalized coordinate space [Default].

This coordinate system is normalized to [0,0]-[1,1] and follows the filmed scene, i.e. static objects in the world have the same coordinates regardless of global rotation.

Parameters
selfThe bbox object
Returns
Success, check errno on error.

◆ bbox_destroy()

bool bbox_destroy ( bbox_t *  self)

Destroy the bbox object.

Parameters
selfThe bbox object
Returns
Success, check errno on error.

◆ bbox_draw_path()

bool bbox_draw_path ( bbox_t *  self)

Draw the current path.

// Draw a polyline
bbox_move_to(bbox, 0.2, 0.2);
bbox_line_to(bbox, 0.5, 0.5);
bbox_line_to(bbox, 0.8, 0.4);
bool bbox_line_to(bbox_t *self, float x, float y)
Adds a point to the current path.
bool bbox_move_to(bbox_t *self, float x, float y)
Move to the specified point.
bool bbox_draw_path(bbox_t *self)
Draw the current path.
Parameters
selfThe bbox object
Returns
Success, check errno on error.

◆ bbox_line()

bool bbox_line ( bbox_t *  self,
float  x1,
float  y1,
float  x2,
float  y2 
)

Create a new Line.

The visible coordinates are in the range 0.0 to 1.0. Coordinates outside of this range will be clipped, this can result in partial lines being drawn.

The effect of this call is delayed until the next bbox_commit

Parameters
selfThe bbox object
x1Left
y1Top
x2Right
y2Bottom
Returns
Success, check errno on error.

◆ bbox_line_to()

bool bbox_line_to ( bbox_t *  self,
float  x,
float  y 
)

Adds a point to the current path.

// Draw a polyline
bbox_move_to(bbox, 0.2, 0.2);
bbox_line_to(bbox, 0.5, 0.5);
bbox_line_to(bbox, 0.8, 0.4);
Parameters
selfThe bbox object
xLeft
yTop
Returns
Success, check errno on error.

◆ bbox_move_to()

bool bbox_move_to ( bbox_t *  self,
float  x,
float  y 
)

Move to the specified point.

// Draw a polyline
bbox_move_to(bbox, 0.2, 0.2);
bbox_line_to(bbox, 0.5, 0.5);
bbox_line_to(bbox, 0.8, 0.4);
Parameters
selfThe bbox object
xLeft
yTop
Returns
Success, check errno on error.

◆ bbox_new()

bbox_t* bbox_new ( size_t  n_channels,
  ... 
)

Create a new bbox object with global coordinate-space.

[0,0]
  ┏━━━━━━━━━━━━━┓
  ┃   ┏━━━━━┓   ┃
  ┃   ┃View1┃   ┃
  ┃   ┗━━━━━┛   ┃
  ┗━━━━━━━━━━━━━┛
              [1,1]
Parameters
n_channelsNumber of channels to draw upon
...List of bbox_channel_t to draw upon
Returns
A bbox object or NULL on error. Free with bbox_destroy.

◆ bbox_quad()

bool bbox_quad ( bbox_t *  self,
float  x1,
float  y1,
float  x2,
float  y2,
float  x3,
float  y3,
float  x4,
float  y4 
)

Create a new Quadrilateral.

The visible coordinates are in the range 0.0 to 1.0. Coordinates outside of this range will be clipped, this can result in partial quads being drawn.

The effect of this call is delayed until the next bbox_commit

Parameters
selfThe bbox object
x1Vertex1
y1Vertex1
x2Vertex2
y2Vertex2
x3Vertex3
y3Vertex3
x4Vertex4
y4Vertex4
Returns
Success, check errno on error.

◆ bbox_rectangle()

bool bbox_rectangle ( bbox_t *  self,
float  x1,
float  y1,
float  x2,
float  y2 
)

Create a new Rectangle.

The visible coordinates are in the range 0.0 to 1.0. Coordinates outside of this range will be clipped, this can result in partial rectangles being drawn.

The effect of this call is delayed until the next bbox_commit

Parameters
selfThe bbox object
x1Left
y1Top
x2Right
y2Bottom
Returns
Success, check errno on error.

◆ bbox_style_corners()

bool bbox_style_corners ( bbox_t *  self)

Replace existing style with ┏━   ━┓ for all new rectangles.

Parameters
selfThe bbox object
Returns
Success, check errno on error.

◆ bbox_style_outline()

bool bbox_style_outline ( bbox_t *  self)

Replace existing style with ┏━━━━━┓ for all new rectangles.

Parameters
selfThe bbox object
Returns
Success, check errno on error.

◆ bbox_thickness_medium()

bool bbox_thickness_medium ( bbox_t *  self)

Change line-thickness to medium for all new geometry.

Parameters
selfThe bbox object
Returns
Success, check errno on error.

◆ bbox_thickness_thick()

bool bbox_thickness_thick ( bbox_t *  self)

Change line-thickness to thick for all new geometry.

Parameters
selfThe bbox object
Returns
Success, check errno on error.

◆ bbox_thickness_thin()

bool bbox_thickness_thin ( bbox_t *  self)

Change line-thickness to thin for all new geometry.

Parameters
selfThe bbox object
Returns
Success, check errno on error.

◆ bbox_video_output()

bool bbox_video_output ( bbox_t *  self,
bool  enabled 
)

Control drawing on video-output.

The effect of this call is delayed until the next bbox_commit

Parameters
selfThe bbox object
enabledEnable or Disable drawing on video-output
Returns
Success, check errno on error.

◆ bbox_view_new()

bbox_t* bbox_view_new ( bbox_channel_t  view)

Create a new bbox object with view coordinate-space.

 ┏━━━━━━━━━━━━━┓
 ┃ [0,0]       ┃
 ┃   ┏━━━━━┓   ┃
 ┃   ┃View1┃   ┃
 ┃   ┗━━━━━┛   ┃
 ┃       [1,1] ┃
 ┗━━━━━━━━━━━━━┛
Parameters
viewThe view to draw upon
Returns
A bbox object or NULL on error. Free with bbox_destroy.