This post show us how to map the cv::Mat
to Eigen matrix without copy the data, it works fine, but there are one thing I do not understand.
Mat A(20, 20, CV_32FC1);
cv::randn(A, 0.0f, 1.0f); // random data
// Map the OpenCV matrix with Eigen:
Eigen::Map<Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>> A_Eigen(A.ptr<float>(), A.rows, A.cols);
The problem is, the Mat A
do not tell the A_Eigen
how many bytes per row it should take, as far as I know the cv::Mat
of OpenCV may or may not do padding on each row, do I need to tell the Eigen how many bytes per row (how?)?, or I can safely omit it?
Ps: I am using Eigen 3