Skip to content

Instantly share code, notes, and snippets.

View meton-robean's full-sized avatar
😀
Focusing

meton-robean meton-robean

😀
Focusing
View GitHub Profile
@meton-robean
meton-robean / arma2opencv.hpp
Created May 7, 2017 11:56 — forked from psycharo-zz/arma2opencv.hpp
convertions between armadillo and opencv
// convert an OpenCV multi-channel matrix to Armadillo cube. A copy is made
template <typename T, int NC>
Cube<T> to_arma(const cv::Mat_<cv::Vec<T, NC>> &src)
{
vector<cv::Mat_<T>> channels;
Cube<T> dst(src.cols, src.rows, NC);
for (int c = 0; c < NC; ++c)
channels.push_back({src.rows, src.cols, dst.slice(c).memptr()});
cv::split(src, channels);
return dst;