我正在使用opencv和Eigen。Eigen:给地图赋值
这里是如何将OpenCV的垫链接到的特征矩阵样本: OpenCV CV::Mat and Eigen::Matrix
的关键是使用本征的地图类型,它可以指向由OpenCV的分配的内存。
根据Eigen文档,Map应该是透明的,实际上所有在矩阵上工作的操作都应该在Map上工作。 https://eigen.tuxfamily.org/dox/group__TutorialMapClass.html
这是上面链接的一些代码。 m2map
点矩阵的内存中调用m2
:
m2map(3) = 7; // this will change m2, since they share the same array
但对我来说,即使是最简单的分配失败:
Eigen::Map<Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>> eigenHeatmap(heatmap.ptr<float>(), heatmap.rows, heatmap.cols);
eigenHeatmap=0.f;
生产:
/.../Code.cpp:69:25: error: no match for ‘operator=’ (operand types are ‘Eigen::Map<Eigen::Matrix<float, -1, -1, 1> >’ and ‘float’)
eigenHeatmap=0.f;
整个错误消息是相当长:https://pastebin.com/i3AWs6C7
我是你sing eigen3.3.3,opencv3.2.0和g ++ 5.4.0