Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cv::eigen2cv and cv2eigen errors

Dear guys,

I'm trying to solve SVD using the Eigen library, since I'm trying to solve one of the biggest error I've got so far in retrieving the fundamental matrix (here the link)

I'm using OpenCV 3.x and I can't compile OpenCV from sources with Eigen and/or LAPACK support, so I downloaded the Eigen library and putted under usr/local/include. No problem so far, I can see Eigen function and variables, so the linker and compiler are ok with that, I suppose. So, since I'm interesting in SVD and since I mostly use OpenCV for my stuff, I would like to write a function that directly compute the SVD for me. I've seen that there are a lot of possibilities to make cv::Mat working as Eigen::Matrix and vice-versa. What I would like is a function that do that:

int runEigenSVD(cv::InputArray _mat,
    cv::OutputArray _U, cv::OutputArray _S, cv::OutputArray _V,
    unsigned int QRPreconditioner,
    unsigned int computationOptions)

I'm not even able to compile since using different approaches I always get different errors. I obtain the input matrix with cv::Mat inputMat = _mat.getMat();, so suppose mat as my input matrix, always.

First try:

//OpenCV-> Eigen
 Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>
            mat_Eigen(inputMat.ptr<double>(), mat.rows, mat.cols);

//Executing Eigen stuff, here SVD
 Eigen::JacobiSVD<Eigen::MatrixXd, Eigen::FullPivHouseholderQRPreconditioner> 
            svd(mat_Eigen, Eigen::ComputeThinU | Eigen::ComputeThinV);

//Eigen -> OpenCV
 int U_row = svd.matrixU().rows();
 int U_cols = svd.matrixU().cols();
 cv::Mat U_OpenCV(U_row, U_cols, CV_64FC1, svd.matrixU().data());

The errors I got are in the last line:

invalid conversion from ‘const void’ to ‘void’ [-fpermissive]

no matching function for call to ‘cv::Mat::Mat(int&, int&, int, const Scalar*)’

Using eigen2cv and cv2eigen

I got always error, using both function, even with simple code like this one:

Eigen::ArrayXXd img, blur;    
cv::eigen2cv(img) = cv::imread("image_01.jpg");

The error I get is:

Invalid arguments ' Candidates are:

void eigen2cv(const ? &, cv::Mat &)

void eigen2cv(const ? &, cv::Matx<#0,int3 #1 0,int3 #2 0> &)'

Any suggestion? The documentation regarding it is like... nothing and it's incredible that nobody else have done it so far!!

cv::eigen2cv and cv2eigen errors

Dear guys,

I'm trying to solve SVD using the Eigen library, since I'm trying to solve one of the biggest error I've got so far in retrieving the fundamental matrix (here the link)

I'm using OpenCV 3.x and I can't compile OpenCV from sources with Eigen and/or LAPACK support, so I downloaded the Eigen library and putted under usr/local/include. No problem so far, I can see Eigen function and variables, so the linker and compiler are ok with that, I suppose. So, since I'm interesting in SVD and since I mostly use OpenCV for my stuff, I would like to write a function that directly compute the SVD for me. I've seen that there are a lot of possibilities to make cv::Mat working as Eigen::Matrix and vice-versa. What I would like is a function that do that:

int runEigenSVD(cv::InputArray _mat,
    cv::OutputArray _U, cv::OutputArray _S, cv::OutputArray _V,
    unsigned int QRPreconditioner,
    unsigned int computationOptions)

I'm not even able to compile since using different approaches I always get different errors. I obtain the input matrix with cv::Mat inputMat = _mat.getMat();, so suppose mat as my input matrix, always.

First try:

//OpenCV-> Eigen
 Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>
            mat_Eigen(inputMat.ptr<double>(), mat.rows, mat.cols);

//Executing Eigen stuff, here SVD
 Eigen::JacobiSVD<Eigen::MatrixXd, Eigen::FullPivHouseholderQRPreconditioner> 
            svd(mat_Eigen, Eigen::ComputeThinU | Eigen::ComputeThinV);

//Eigen -> OpenCV
 int U_row = svd.matrixU().rows();
 int U_cols = svd.matrixU().cols();
 cv::Mat U_OpenCV(U_row, U_cols, CV_64FC1, svd.matrixU().data());

The errors I got are in the last line:

invalid conversion from ‘const void’ to ‘void’ [-fpermissive]

no matching function for call to ‘cv::Mat::Mat(int&, int&, int, const Scalar*)’

Using eigen2cv and cv2eigen

I got always error, using both function, even with simple code like this one:

Eigen::ArrayXXd img, blur;    
cv::eigen2cv(img) = cv::imread("image_01.jpg");

The error I get is:

Invalid arguments ' Candidates are:

void eigen2cv(const ? &, cv::Mat &)

void eigen2cv(const ? &, cv::Matx<#0,int3 #1 0,int3 #2 0> &)'

Any suggestion? The documentation regarding it is like... nothing and it's incredible that nobody else have done it so far!!

cv::eigen2cv Mat to Eigen, eigen2cv and cv2eigen errors

Dear guys,

I'm trying to solve SVD using the Eigen library, since I'm trying to solve one of the biggest error I've got so far in retrieving the fundamental matrix (here the link)

I'm using OpenCV 3.x and I can't compile OpenCV from sources with Eigen and/or LAPACK support, so I downloaded the Eigen library and putted under usr/local/include. No problem so far, I can see Eigen function and variables, so the linker and compiler are ok with that, I suppose. So, since I'm interesting in SVD and since I mostly use OpenCV for my stuff, I would like to write a function that directly compute the SVD for me. I've seen that there are a lot of possibilities to make cv::Mat working as Eigen::Matrix and vice-versa. What I would like is a function that do that:

int runEigenSVD(cv::InputArray _mat,
    cv::OutputArray _U, cv::OutputArray _S, cv::OutputArray _V,
    unsigned int QRPreconditioner,
    unsigned int computationOptions)

I'm not even able to compile since using different approaches I always get different errors. I obtain the input matrix with cv::Mat inputMat = _mat.getMat();, so suppose mat as my input matrix, always.

First try:

//OpenCV-> Eigen
 Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>
            mat_Eigen(inputMat.ptr<double>(), mat.rows, mat.cols);

//Executing Eigen stuff, here SVD
 Eigen::JacobiSVD<Eigen::MatrixXd, Eigen::FullPivHouseholderQRPreconditioner> 
            svd(mat_Eigen, Eigen::ComputeThinU | Eigen::ComputeThinV);

//Eigen -> OpenCV
 int U_row = svd.matrixU().rows();
 int U_cols = svd.matrixU().cols();
 cv::Mat U_OpenCV(U_row, U_cols, CV_64FC1, svd.matrixU().data());

The errors I got are in the last line:

invalid conversion from ‘const void’ to ‘void’ [-fpermissive]

no matching function for call to ‘cv::Mat::Mat(int&, int&, int, const Scalar*)’

Using eigen2cv and cv2eigen

I got always error, using both function, even with simple code like this one:

Eigen::ArrayXXd img, blur;    
cv::eigen2cv(img) cv::Mat_<float> a = cv::imread("image_01.jpg");
Mat_<float>::ones(2,2);
Eigen::Matrix<float,Eigen::Dynamic,Eigen::Dynamic> b;
cv::cv2eigen(a,b);

The error I get is:

Invalid arguments ' Candidates are:

void eigen2cv(const ? &, cv::Mat &)

void eigen2cv(const ? &, cv::Matx<#0,int3 #1 0,int3 #2 0> &)'

Any suggestion? The documentation regarding it is like... nothing and it's incredible that nobody else have done it so far!!

Mat to Eigen, eigen2cv and cv2eigen errors

Dear guys,

I'm trying to solve SVD using the Eigen library, since I'm trying to solve one of the biggest error I've got so far in retrieving the fundamental matrix (here the link)

I'm using OpenCV 3.x and I can't compile OpenCV from sources with Eigen and/or LAPACK support, so I downloaded the Eigen library and putted under usr/local/include. No problem so far, I can see Eigen function and variables, so the linker and compiler are ok with that, I suppose. So, since I'm interesting in SVD and since I mostly use OpenCV for my stuff, I would like to write a function that directly compute the SVD for me. I've seen that there are a lot of possibilities to make cv::Mat working as Eigen::Matrix and vice-versa. What I would like is a function that do that:

int runEigenSVD(cv::InputArray _mat,
    cv::OutputArray _U, cv::OutputArray _S, cv::OutputArray _V,
    unsigned int QRPreconditioner,
    unsigned int computationOptions)

I'm not even able to compile since using different approaches I always get different errors. I obtain the input matrix with cv::Mat inputMat = _mat.getMat();, so suppose mat as my input matrix, always.always.

First try:

//OpenCV-> Eigen
Eigen: it works!
 Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>
            mat_Eigen(inputMat.ptr<double>(), mat.rows, mat.cols);

//Executing Eigen stuff, here SVD
 Eigen::JacobiSVD<Eigen::MatrixXd, Eigen::FullPivHouseholderQRPreconditioner> 
            svd(mat_Eigen, Eigen::ComputeThinU | Eigen::ComputeThinV);

//Eigen -> OpenCV
 int U_row = svd.matrixU().rows();
 int U_cols = svd.matrixU().cols();
 cv::Mat U_OpenCV(U_row, U_cols, CV_64FC1, svd.matrixU().data());

The errors I got are in the last line:

invalid conversion from ‘const void’ to ‘void’ [-fpermissive]

no matching function for call to ‘cv::Mat::Mat(int&, int&, int, const Scalar*)’

Using eigen2cv and cv2eigen

I got always error, using both function, even with simple code like this one:

cv::Mat_<float> a = Mat_<float>::ones(2,2);
Eigen::Matrix<float,Eigen::Dynamic,Eigen::Dynamic> b;
cv::cv2eigen(a,b);

The error I get is:

Invalid arguments ' Candidates are:

void eigen2cv(const ? &, cv::Mat &)

void eigen2cv(const ? &, cv::Matx<#0,int3 #1 0,int3 #2 0> &)'

Any suggestion? The documentation regarding it is like... nothing and it's incredible that nobody else have done it so far!!

EDIT ## I'm able to map from Mat to Eigen, but still find no way to map it back without the use of for-loop