Banuba SDK
Typedefs | Enumerations | Functions | Variables
Types

Typedefs

using bnb::high_res_timer = std::chrono::high_resolution_clock
 
using bnb::time_stamp_t = std::chrono::time_point< std::chrono::high_resolution_clock >
 
using bnb::orientation = camera_orientation
 
using bnb::color_plane_data_t = std::uint8_t
 
using bnb::color_plane = std::shared_ptr< color_plane_data_t >
 

Enumerations

enum  bnb::pixel_buffer_format : int32_t {
  bpc8_rgb = 0x0101, bpc8_bgr = 0x0102, bpc8_rgba = 0x0103, bpc8_bgra = 0x0104,
  bpc8_argb = 0x0105, nv12 = 0x0201, i420 = 0x0401
}
 bt601 and bt709 - two standards for representing color space that use the same image encoding/decoding algorithm. More...
 
enum  bnb::color_range { video, bnb::color_range::full }
 Enum class represents color range. More...
 
enum  bnb::color_std { bt601, bt709 }
 Enum class represents suppotred color standarts.
 
enum  bnb::yuv_format { yuv_nv12, yuv_i420 }
 Enum class represents supported yuv formats.
 
enum  bnb::camera_orientation : unsigned int {
  deg_0 = 0, deg_90 = 1, deg_180 = 2, deg_270 = 3,
  up = deg_0, left = deg_90, down = deg_180, right = deg_270
}
 camera image layout is top-left, 0 orientation is portrait, rotation is counterclockwise
 
enum  bnb::rect_fit_mode : uint8_t { bnb::rect_fit_mode::fit_width, bnb::rect_fit_mode::fit_height, bnb::rect_fit_mode::fit_inside, bnb::rect_fit_mode::fit_outside }
 

Functions

bool bnb::pixel_buffer_format_is_bpc8 (pixel_buffer_format format)
 
bool bnb::pixel_buffer_format_is_nv12 (pixel_buffer_format format)
 
bool bnb::pixel_buffer_format_is_i420 (pixel_buffer_format format)
 
bool bnb::pixel_buffer_format_is_yuv (pixel_buffer_format format)
 
std::string_view bnb::pixel_buffer_format_to_str (pixel_buffer_format format)
 
color_plane bnb::color_plane_vector (std::vector< color_plane_data_t > vector)
 
color_plane bnb::color_plane_string (std::string str)
 
color_plane bnb::color_plane_char_arr (const char *ptr, size_t size)
 
color_plane bnb::color_plane_weak (const color_plane_data_t *ptr)
 
color_plane bnb::color_plane_data (data_t &&data)
 
void bnb::fit_rects_aspect_ratio (pixel_rect &source_rect, pixel_rect &target_rect, rect_fit_mode mode=rect_fit_mode::fit_inside)
 Adjust rects to have the same aspect ratio as if fitting source_rect into target_rect according to mode, return source_rect, target_rect have the same (+-rounding) aspect ratio, and are always not exceeding corresponding input rect, preserving original centers. More...
 
void bnb::fill_exterior (uint8_t *pixels, uint32_t width, uint32_t height, uint32_t channels, pixel_rect rect, uint8_t color, bool edge_repeat=false)
 
void bnb::transform (const uint8_t *src, uint32_t src_w, uint32_t src_h, uint8_t *dst, uint32_t dst_w, uint32_t dst_h, uint32_t channels, const transformation &t)
 Transform src image to dst. More...
 
void bnb::transform (const float *src, uint32_t src_w, uint32_t src_h, float *dst, uint32_t dst_w, uint32_t dst_h, uint32_t channels, const transformation &t)
 Transform src image to dst. More...
 
void bnb::transform (const uint8_t *src, uint32_t src_w, uint32_t src_h, uint8_t *dst, uint32_t dst_w, uint32_t dst_h, uint32_t channels, const transformation &from, const transformation &to)
 Transform src image to dst through common basis NOTE: both transformations should be (common -> image) More...
 
void bnb::transform1x1 (const uint8_t *src, uint8_t *dst, uint32_t w, uint32_t h, uint32_t channels, const transformation &t)
 Transform src image to dst param src, dst source, destination image buffers param w, h source, destination width and height param channels number of channels per pixel param t transformation (src -> dst) to apply.
 
point2d bnb::transform (const point2d &point, const transformation &t)
 Apply transformation to point. More...
 
point2d bnb::transform (const point2d &point, const transformation &from, const transformation &to)
 Transform point through common basis Apply transformation to point from some basis to another one through common basis NOTE: both transformations should be (common -> image) param point 2D point to transform param from,to transformations (common -> image) to apply by formula (from -> common -> to) return result 2D point.
 
pixel_rect bnb::transform (const pixel_rect &rect, const transformation &t)
 Apply transformation to rect Result is normalized wrt. More...
 
bool bnb::pixel_rect::is_valid () const
 
void bnb::pixel_rect::transpose ()
 
pixel_rect bnb::pixel_rect::intersect (const pixel_rect &rect) const
 
bool bnb::pixel_rect::operator== (const pixel_rect &cmp) const noexcept
 
bool bnb::pixel_rect::operator!= (const pixel_rect &cmp) const noexcept
 
 bnb::pixel_rect::pixel_rect (int32_t _x, int32_t _y, int32_t _w, int32_t _h)
 
 bnb::pixel_rect::pixel_rect (int32_t _w, int32_t _h)
 
 bnb::pixel_rect::pixel_rect (const interfaces::pixel_rect &rect)
 
interfaces::pixel_rect bnb::pixel_rect::get_iface () const
 
 bnb::pixel_rect::operator interfaces::pixel_rect () const
 
template<typename T >
const T & bnb::full_image_t::get_data () const noexcept
 
template<typename T >
bool bnb::full_image_t::has_data () const noexcept
 
interfaces::point2d bnb::transformation::transform_point (const interfaces::point2d &p) const override
 Apply transform to point.
 
interfaces::pixel_rect bnb::transformation::transform_rect (const interfaces::pixel_rect &rect) const override
 

Variables

int32_t bnb::pixel_rect::x = 0
 
int32_t bnb::pixel_rect::y = 0
 
int32_t bnb::pixel_rect::w = 0
 
int32_t bnb::pixel_rect::h = 0
 

Detailed Description

Enumeration Type Documentation

◆ color_range

enum bnb::color_range
strong

Enum class represents color range.

Enumerator
full 

for y values range is 16-235, for u and v values range is 16-240

Definition at line 239 of file full_image.hpp.

240  {
241  video, /** for y values range is 16-235, for u and v values range is 16-240 */
242  full, /** for y, u and v values range is 0-255 */
243  };

◆ pixel_buffer_format

enum bnb::pixel_buffer_format : int32_t
strong

bt601 and bt709 - two standards for representing color space that use the same image encoding/decoding algorithm.

Differ in the encoding / decoding coefficients.

Definition at line 28 of file full_image.hpp.

28  : int32_t
29  {
30  bpc8_rgb = 0x0101, // one plane: RGB
31  bpc8_bgr = 0x0102, // one plane: BGR
32  bpc8_rgba = 0x0103, // one plane: RGBA
33  bpc8_bgra = 0x0104, // one plane: BGRA
34  bpc8_argb = 0x0105, // one plane: ARGB
35  nv12 = 0x0201, // two planes: first RED, second RG
36  i420 = 0x0401 // three planes: first RED, second RED, third RED
37  }; // enum class pixel_buffer_format

◆ rect_fit_mode

enum bnb::rect_fit_mode : uint8_t
strong
Enumerator
fit_width 

Always fit to width, rect_scale = w_t / w_f.

fit_height 

Always fit to height, rect_scale = h_t / h_f.

fit_inside 

Fit all source inside target = fit to min rect_scale of width and height modes.

fit_outside 

Fit to fill all target = fit to max rect_scale of width and height modes.

Definition at line 22 of file transformation.hpp.

22  : uint8_t
23  {
24  fit_width, //!< Always fit to width, rect_scale = w_t / w_f
25  fit_height, //!< Always fit to height, rect_scale = h_t / h_f
26  fit_inside, //!< Fit all source inside target = fit to min rect_scale of width and height modes
27  fit_outside //!< Fit to fill all target = fit to max rect_scale of width and height modes
28  };

Function Documentation

◆ fit_rects_aspect_ratio()

void bnb::fit_rects_aspect_ratio ( pixel_rect source_rect,
pixel_rect target_rect,
rect_fit_mode  mode = rect_fit_mode::fit_inside 
)

Adjust rects to have the same aspect ratio as if fitting source_rect into target_rect according to mode, return source_rect, target_rect have the same (+-rounding) aspect ratio, and are always not exceeding corresponding input rect, preserving original centers.

May do some per-axis scale adjustments within small margin for fast, integral and/or pixel-perfect scaling between pixel rects

◆ get_data()

template<typename T >
const T & bnb::full_image_t::get_data
inlinenoexcept
Returns
Returns the image object if T is yuv or bpc8 image and at the same time yuv or bpc8 image saved.

Definition at line 716 of file full_image.hpp.

717  {
718  static_assert(std::is_base_of<base_image_t, T>::value, "Type is not image_t");
719  BNB_ASSERT(std::holds_alternative<T>(m_image));
720  return *std::get_if<T>(&m_image);
721  }

◆ has_data()

template<typename T >
bool bnb::full_image_t::has_data
inlinenoexcept
Returns
Returns true if T is yuv or bpc8 image and at the same time yuv or bpc8 image saved.

Definition at line 724 of file full_image.hpp.

725  {
726  static_assert(std::is_base_of<base_image_t, T>::value, "Type is not image_t");
727  return std::holds_alternative<T>(m_image);
728  }

◆ transform() [1/5]

void bnb::transform ( const float *  src,
uint32_t  src_w,
uint32_t  src_h,
float *  dst,
uint32_t  dst_w,
uint32_t  dst_h,
uint32_t  channels,
const transformation t 
)

Transform src image to dst.

Parameters
src,src_w,src_hsource 32 bit float image buffer, width and height
dst,dst_w,dst_hdestination 32 bit float image buffer, width and height
channelsnumber of channels per pixel
ttransformation (src -> dst) to apply

◆ transform() [2/5]

pixel_rect bnb::transform ( const pixel_rect rect,
const transformation t 
)

Apply transformation to rect Result is normalized wrt.

flips/rotates so that w > 0 && h > 0

Parameters
rectpixel_rect to transform
ttransformation to apply
Returns
result pixel_rect

◆ transform() [3/5]

point2d bnb::transform ( const point2d point,
const transformation t 
)

Apply transformation to point.

Parameters
point2D point to transform
ttransformation to apply
Returns
result 2D point

◆ transform() [4/5]

void bnb::transform ( const uint8_t *  src,
uint32_t  src_w,
uint32_t  src_h,
uint8_t *  dst,
uint32_t  dst_w,
uint32_t  dst_h,
uint32_t  channels,
const transformation from,
const transformation to 
)
inline

Transform src image to dst through common basis NOTE: both transformations should be (common -> image)

Parameters
src,src_w,src_hsource image buffer, width and height
dst,dst_w,dst_hdestination image buffer, width and height
channelsnumber of channels per pixel
from,totransformations (common -> image) to apply by formula (from -> common -> to)

Definition at line 227 of file transformation.hpp.

228  {
229  transform(src, src_w, src_h, dst, dst_w, dst_h, channels, from.inverse() >> to);
230  }

◆ transform() [5/5]

void bnb::transform ( const uint8_t *  src,
uint32_t  src_w,
uint32_t  src_h,
uint8_t *  dst,
uint32_t  dst_w,
uint32_t  dst_h,
uint32_t  channels,
const transformation t 
)

Transform src image to dst.

Parameters
src,src_w,src_hsource uint8_t image buffer, width and height
dst,dst_w,dst_hdestination uint8_t image buffer, width and height
channelsnumber of channels per pixel
ttransformation (src -> dst) to apply
bnb::rect_fit_mode::fit_inside
@ fit_inside
Fit all source inside target = fit to min rect_scale of width and height modes.
bnb::rect_fit_mode::fit_height
@ fit_height
Always fit to height, rect_scale = h_t / h_f.
bnb::rect_fit_mode::fit_width
@ fit_width
Always fit to width, rect_scale = w_t / w_f.
bnb::rect_fit_mode::fit_outside
@ fit_outside
Fit to fill all target = fit to max rect_scale of width and height modes.
bnb::transform
pixel_rect transform(const pixel_rect &rect, const transformation &t)
Apply transformation to rect Result is normalized wrt.