27 NumpyFile(
const std::filesystem::path &fname,
const std::string &mode =
"r",
FileConfig cfg = {});
32 std::vector<Frame>
read(
size_t n_frames)
override;
34 void read_into(std::byte *image_buf,
size_t n_frames)
override;
35 size_t frame_number(
size_t frame_index)
override {
return frame_index; };
66 fread(arr.data(),
sizeof(T), arr.size(),
fp);
uint8_t bitdepth() const
Definition DType.cpp:36
FileInterface class to define the interface for file operations.
Definition FileInterface.hpp:33
Definition NDArray.hpp:23
NumpyFile class to read and write numpy files.
Definition NumpyFile.hpp:18
size_t tell() override
get the current position of the file pointer
Definition NumpyFile.hpp:39
std::vector< size_t > shape() const
get the shape of the numpy file
Definition NumpyFile.hpp:55
size_t current_frame
Definition NumpyFile.hpp:75
void write(Frame &frame) override
write a frame to the file
Definition NumpyFile.cpp:31
FILE * fp
Definition NumpyFile.hpp:73
void load_metadata()
Definition NumpyFile.cpp:103
ssize_t rows() const override
get the number of rows in the file
Definition NumpyFile.hpp:41
size_t pixels() override
get the number of pixels in one frame
Definition NumpyFile.cpp:58
uint8_t minor_ver_
Definition NumpyFile.hpp:81
size_t bytes_per_frame() override
get the size of one frame in bytes
Definition NumpyFile.cpp:61
uint8_t header_len_size
Definition NumpyFile.hpp:77
uint8_t major_ver_
Definition NumpyFile.hpp:80
size_t header_size
Definition NumpyFile.hpp:78
Frame read() override
write a vector of frames to the file
Definition NumpyFile.hpp:30
size_t initial_header_len
Definition NumpyFile.hpp:74
void read_into(std::byte *image_buf) override
read one frame from the file at the current position and store it in the provided buffer
Definition NumpyFile.hpp:33
NumpyHeader m_header
Definition NumpyFile.hpp:79
NDArray< T, NDim > load()
load the numpy file into an NDArray
Definition NumpyFile.hpp:63
size_t frame_number(size_t frame_index) override
get the frame number at the given frame index
Definition NumpyFile.hpp:35
Frame get_frame(size_t frame_number)
Definition NumpyFile.cpp:42
void get_frame_into(size_t, std::byte *)
Definition NumpyFile.cpp:47
DType dtype() const
get the data type of the numpy file
Definition NumpyFile.hpp:49
ssize_t cols() const override
get the number of columns in the file
Definition NumpyFile.hpp:42
void seek(size_t frame_number) override
seek to the given frame number
Definition NumpyFile.hpp:38
~NumpyFile()
Definition NumpyFile.cpp:80
ssize_t bitdepth() const override
get the bitdepth of the file
Definition NumpyFile.hpp:43
size_t total_frames() const override
get the total number of frames in the file
Definition NumpyFile.hpp:40
uint32_t header_len
Definition NumpyFile.hpp:76
Frame class to represent a single frame of data model class should be able to work with streams comin...
Definition CircularFifo.hpp:11
FileConfig structure to store the configuration of a file dtype: data type of the file rows: number o...
Definition FileInterface.hpp:17