I am trying to convert a cv::Mat to Eigen::Mat with cv2eigen and back with eigen2cv (I understand that one should preferably use Eigen::Map for that, but that is a different story).
I am using OpenCV 2.4.9 and eigen3 3.0.5 in conjunction with Eclipse 3.7.2 on ubuntu 12.04 LTS
However, even with the simple example
#include <Eigen/Dense>
#include <opencv2/core/eigen.hpp>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
using namespace Eigen;
int main() {
cv::Mat_<float> a = Mat_<float>::ones(2,2);
Eigen::Matrix<float,Dynamic,Dynamic> b;
cv2eigen(a,b);
return 0;
}
(main body taken from cv::Mat conversion to Eigen-Matrix and back) I get the following compile error:
Invalid arguments ' Candidates are: void cv2eigen(const cv::Matx<#0,1,#1> &, ? &) void cv2eigen(const cv::Matx<#0,#1,#2> &, ? &) void cv2eigen(const cv::Matx<#0,#1,1> &, ? &) void cv2eigen(const cv::Mat &, ? &) void cv2eigen(const cv::Matx<#0,#1,#2> &, ? &) void cv2eigen(const cv::Mat &, ? &) ' simpleExample.cpp /simpleExample_proj-Debug@build/[Source directory] line 17 Semantic Error
I took a peek into opencv2/core/eigen.hpp and suppose that the method I want to call is the following one:
template<typename _Tp>
void cv2eigen( const Mat& src,
Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst )
{
...
}
Looks like something is wrong with the parameters' types, i.e. the matrices but I cannot figure out what - the same code seems to work for other people. Any help/ hint is greatly appreciated!
P.S.: If I forgot to post any crucial detail, my apologies, just tell me so and I will fix that.
Edit Thought I might mention it: I am using the stock gcc version 4.6.3 that comes with ubuntu.