Frame

class Frame

Frame class to represent a single frame of data. Not much more than a pointer and some info. Limited interface to accept frames from many sources.

Public Functions

Frame(uint32_t rows, uint32_t cols, Dtype dtype)

Construct a new Frame.

Note

the data is initialized to zero

Parameters:
  • rows – number of rows

  • cols – number of columns

  • dtype – data type of the pixels

Frame(const std::byte *bytes, uint32_t rows, uint32_t cols, Dtype dtype)

Construct a new Frame.

Parameters:
  • bytes – pointer to the data to be copied into the frame

  • rows – number of rows

  • cols – number of columns

  • dtype – data type of the pixels

inline ~Frame()
Frame &operator=(const Frame &other) = delete

Warning

Copy is disabled to ensure performance when passing frames around. Can discuss enabling it.

Frame(const Frame &other) = delete
Frame &operator=(Frame &&other) noexcept
Frame(Frame &&other) noexcept
Frame clone() const
uint32_t rows() const
uint32_t cols() const
size_t bitdepth() const
Dtype dtype() const
uint64_t size() const
size_t bytes() const
std::byte *data() const
std::byte *pixel_ptr(uint32_t row, uint32_t col) const

Get the pointer to the pixel at the given row and column.

Warning

The user should cast the pointer to the appropriate type. Think twice if this is the function you want to use.

Parameters:
  • row – row index

  • col – column index

Returns:

pointer to the pixel

template<typename T>
inline void set(uint32_t row, uint32_t col, T data)

Set the pixel at the given row and column to the given value.

Template Parameters:

T – type of the value

Parameters:
  • row – row index

  • col – column index

  • data – value to set

template<typename T>
inline T get(uint32_t row, uint32_t col)
template<typename T>
inline NDView<T, 2> view()

Return an NDView of the frame. This is the preferred way to access data in the frame.

Template Parameters:

T – type of the pixels

Returns:

NDView<T, 2>

template<typename T>
inline NDArray<T> image()

Copy the frame data into a new NDArray. This is a deep copy.

Private Members

uint32_t m_rows
uint32_t m_cols
Dtype m_dtype
std::byte *m_data