4#include <opencv2/opencv.hpp>
7template <
typename T,
int NC>
8Cube<T> to_arma(
const cv::Mat_<cv::Vec<T, NC>> &src)
10 vector<cv::Mat_<T>> channels;
11 Cube<T> dst(src.cols, src.rows, NC);
12 for (
int c = 0; c < NC; ++c)
13 channels.push_back({ src.rows, src.cols, dst.slice(c).memptr() });
14 cv::split(src, channels);
20Mat<T> to_arma(
const cv::Mat_<T> &src)
22 Mat<T> dst(src.cols, src.rows);
23 src.copyTo({ src.rows, src.cols, dst.memptr() });
29cv::Mat to_cvmat(
const Cube<T> &src)
31 vector<cv::Mat_<T>> channels;
32 for (
size_t c = 0; c < src.n_slices; ++c)
34 auto *data =
const_cast<T*
>(src.slice(c).memptr());
35 channels.push_back({
int(src.n_cols),
int(src.n_rows), data });
38 cv::merge(channels, dst);
44cv::Mat_<T> to_cvmat(
const Mat<T> &src)
46 return cv::Mat_<double>{
int(src.n_cols),
int(src.n_rows),
const_cast<T*
>(src.memptr())};