gpt4 book ai didi

c++ - 使用 cv2eigen 将 cv::Mat1f 转换为 Eigen::MatrixXf 时出错?

转载 作者:行者123 更新时间:2023-11-28 01:50:16 32 4
gpt4 key购买 nike

我有这个代码:

#include "opencv2/core.hpp"
#include "opencv2/core/eigen.hpp"
#include <Eigen/Dense>


void CloudCache::DoPcaEigen(int dim){
cv::Mat1f codes;
...
Eigen::MatrixXf X = Eigen::MatrixXf(codes.rows,codes.cols);
cv::cv2eigen(codes, X);
...
}

我编译它包括 -I/home/luca/eigen/icpc

但是我得到这个错误:

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(63): error #303: explicit type is missing ("int" assumed)
void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& src, Mat& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(63): error: expected a ")"
void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& src, Mat& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(81): error #303: explicit type is missing ("int" assumed)
void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& src,
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(81): error: expected a ")"
void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& src,
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(81): error: function template "cv::eigen2cv" has already been defined
void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& src,
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(96): error: identifier "Eigen" is undefined
Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(96): error: Matrix is not a template
Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(96): error: expected a ","
Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(124): error: identifier "Eigen" is undefined
Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(124): error: Matrix is not a template
Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(124): error: expected a ","
Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(142): error: identifier "Eigen" is undefined
Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(142): error: Matrix is not a template
Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(142): error: name followed by "::" must be a class or namespace name
Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(142): error: name followed by "::" must be a class or namespace name
Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(142): error: expected a ","
Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(170): error: identifier "Eigen" is undefined
Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(170): error: Matrix is not a template
Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(170): error: name followed by "::" must be a class or namespace name
Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(170): error: name followed by "::" must be a class or namespace name
Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(170): error: expected a ","
Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(189): error: identifier "Eigen" is undefined
Eigen::Matrix<_Tp, Eigen::Dynamic, 1>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(189): error: Matrix is not a template
Eigen::Matrix<_Tp, Eigen::Dynamic, 1>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(189): error: name followed by "::" must be a class or namespace name
Eigen::Matrix<_Tp, Eigen::Dynamic, 1>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(189): error: expected a ","
Eigen::Matrix<_Tp, Eigen::Dynamic, 1>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(188): error: function template "cv::cv2eigen<_Tp>(const cv::Mat &, <error-type>, <error-type> &)" has already been defined
void cv2eigen( const Mat& src,
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(214): error: identifier "Eigen" is undefined
Eigen::Matrix<_Tp, Eigen::Dynamic, 1>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(214): error: Matrix is not a template
Eigen::Matrix<_Tp, Eigen::Dynamic, 1>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(214): error: name followed by "::" must be a class or namespace name
Eigen::Matrix<_Tp, Eigen::Dynamic, 1>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(214): error: expected a ","
Eigen::Matrix<_Tp, Eigen::Dynamic, 1>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(235): error: identifier "Eigen" is undefined
Eigen::Matrix<_Tp, 1, Eigen::Dynamic>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(235): error: Matrix is not a template
Eigen::Matrix<_Tp, 1, Eigen::Dynamic>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(235): error: name followed by "::" must be a class or namespace name
Eigen::Matrix<_Tp, 1, Eigen::Dynamic>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(235): error: expected a ","
Eigen::Matrix<_Tp, 1, Eigen::Dynamic>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(234): error: function template "cv::cv2eigen<_Tp>(const cv::Mat &, <error-type>, <error-type> &)" has already been defined
void cv2eigen( const Mat& src,
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(259): error: identifier "Eigen" is undefined
Eigen::Matrix<_Tp, 1, Eigen::Dynamic>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(259): error: Matrix is not a template
Eigen::Matrix<_Tp, 1, Eigen::Dynamic>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(259): error: name followed by "::" must be a class or namespace name
Eigen::Matrix<_Tp, 1, Eigen::Dynamic>& dst )
^

In file included from ../Core/CCCore.cpp(14):
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(259): error: expected a ","
Eigen::Matrix<_Tp, 1, Eigen::Dynamic>& dst )
^

../Core/CCCore.cpp(244): error: no instance of overloaded function "cv::cv2eigen" matches the argument list
argument types are: (cv::Mat1f, Eigen::MatrixXf)
cv::cv2eigen(codes, X);
^
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(258): note: this candidate was rejected because mismatch in count of arguments
void cv2eigen( const Matx<_Tp, 1, _cols>& src,
^
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(213): note: this candidate was rejected because mismatch in count of arguments
void cv2eigen( const Matx<_Tp, _rows, 1>& src,
^
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(169): note: this candidate was rejected because mismatch in count of arguments
void cv2eigen( const Matx<_Tp, _rows, _cols>& src,
^
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(141): note: this candidate was rejected because mismatch in count of arguments
void cv2eigen( const Mat& src,
^
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(123): note: this candidate was rejected because mismatch in count of arguments
void cv2eigen( const Matx<_Tp, _rows, _cols>& src,
^
/home/luca/ParallelOpenCV/install_icpc/include/opencv2/core/eigen.hpp(95): note: this candidate was rejected because mismatch in count of arguments
void cv2eigen( const Mat& src,

为什么会这样?

最佳答案

好像#include "opencv2/core/eigen.hpp"不包含Eigen本身,所以需要

#include <Eigen/Core>

在那之前。

关于c++ - 使用 cv2eigen 将 cv::Mat1f 转换为 Eigen::MatrixXf 时出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43302131/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com