OpenCV Mat has a pointer to its data. Armadillo has a constructor that can read from external data. Easy to put them together. Remember that Armadillo is stored in the main order, while OpenCV uses a series of lines. I suppose you will need to add another step to convert before or after.
cv::Mat opencv_mat; //opencv mat, already transposed. arma::mat arma_mat( reinterpret_cast<double*>opencv_mat.data, opencv_mat.rows, opencv_mat.cols )
The cv::Mat constructor has a form that takes a pointer to the data, and arma::mat has a function for double * pointers to its data, called memptr ().
So, if you want to convert from arma::mat to cv::Mat , this should work:
cv::Mat opencv_mat( rows, cols, CV_64FC1, arma_mat.memptr() )
a-jays
source share