22 #ifndef MATCEREALISATION_HPP_
23 #define MATCEREALISATION_HPP_
25 #include "opencv2/core/core.hpp"
42 template<
class Archive>
43 void save(Archive& ar,
const cv::Mat& mat)
51 continuous = mat.isContinuous();
53 ar & rows & cols & type & continuous;
56 const int data_size = rows * cols *
static_cast<int>(mat.elemSize());
57 auto mat_data = cereal::binary_data(mat.ptr(), data_size);
61 const int row_size = cols *
static_cast<int>(mat.elemSize());
62 for (
int i = 0; i < rows; i++) {
63 auto row_data = cereal::binary_data(mat.ptr(i), row_size);
77 template<
class Archive>
78 void load(Archive& ar, cv::Mat& mat)
83 ar & rows & cols & type & continuous;
86 mat.create(rows, cols, type);
87 const int data_size = rows * cols *
static_cast<int>(mat.elemSize());
88 auto mat_data = cereal::binary_data(mat.ptr(), data_size);
92 mat.create(rows, cols, type);
93 const int row_size = cols *
static_cast<int>(mat.elemSize());
94 for (
int i = 0; i < rows; i++) {
95 auto row_data = cereal::binary_data(mat.ptr(i), row_size);
void save(Archive &ar, const cv::Mat &mat)
Definition: mat_cerealisation.hpp:43
void load(Archive &ar, cv::Mat &mat)
Definition: mat_cerealisation.hpp:78