25 Frame(ssize_t rows, ssize_t cols, ssize_t m_bitdepth);
26 Frame(std::byte *fp, ssize_t rows, ssize_t cols, ssize_t m_bitdepth);
27 std::byte *
get(
int row,
int col);
30 template <
typename T>
void set(
int row,
int col, T data) {
31 assert(
sizeof(T) == m_bitdepth / 8);
32 if (row < 0 || row >= m_rows || col < 0 || col >= m_cols) {
33 throw std::out_of_range(
"Invalid row or column index");
35 std::memcpy(m_data + (row * m_cols + col) * (m_bitdepth / 8), &data, m_bitdepth / 8);
38 ssize_t
rows()
const {
return m_rows; }
39 ssize_t
cols()
const {
return m_cols; }
40 ssize_t
bitdepth()
const {
return m_bitdepth; }
41 ssize_t
size()
const {
return m_rows * m_cols * m_bitdepth / 8; }
42 std::byte *
data()
const {
return m_data; }
45 m_rows = other.
rows();
46 m_cols = other.
cols();
48 m_data =
new std::byte[m_rows * m_cols * m_bitdepth / 8];
49 std::memcpy(m_data, other.
m_data, m_rows * m_cols * m_bitdepth / 8);
54 m_rows = other.rows();
55 m_cols = other.cols();
56 m_bitdepth = other.bitdepth();
57 m_data = other.m_data;
58 other.m_data =
nullptr;
59 other.m_rows = other.m_cols = other.m_bitdepth = 0;
63 m_rows = other.
rows();
64 m_cols = other.
cols();
66 m_data =
new std::byte[m_rows * m_cols * m_bitdepth / 8];
67 std::memcpy(m_data, other.
m_data, m_rows * m_cols * m_bitdepth / 8);
71 std::vector<ssize_t> shape = {m_rows, m_cols};
72 T *
data =
reinterpret_cast<T *
>(m_data);
ssize_t size() const
Definition Frame.hpp:41
ssize_t m_bitdepth
Definition Frame.hpp:21
ssize_t m_rows
Definition Frame.hpp:19
Frame(Frame &&other)
Definition Frame.hpp:53
ssize_t m_cols
Definition Frame.hpp:20
ssize_t rows() const
Definition Frame.hpp:38
std::byte * data() const
Definition Frame.hpp:42
ssize_t cols() const
Definition Frame.hpp:39
std::byte * get(int row, int col)
Definition Frame.cpp:19
~Frame()
Definition Frame.hpp:78
Frame(const Frame &other)
Definition Frame.hpp:62
NDArray< T > image()
Definition Frame.hpp:76
Frame & operator=(Frame &other)
Definition Frame.hpp:44
void set(int row, int col, T data)
Definition Frame.hpp:30
ssize_t bitdepth() const
Definition Frame.hpp:40
NDView< T > view()
Definition Frame.hpp:70
std::byte * m_data
Definition Frame.hpp:22
Definition NDArray.hpp:23
Frame class to represent a single frame of data model class should be able to work with streams comin...
Definition CircularFifo.hpp:11