我在C++中使用Eigen3 Library 和OpenCV应用程序时遇到了麻烦。我已经使用以下命令在我的 Ubuntu 上安装了 Eigen3 库:
sudo apt-get install libeigen3-dev
当我使用以下命令进行编译时,我能够编译和使用示例 Eigen3 应用程序(安装了 Eigen3 库并且它可以工作)。
g++ -I/usr/include/eigen3 Eig.cpp -o Eig
我想将已安装的 Eigen 库与 OpenCV 一起使用。
我用以下标志编译了 OpenCV 源代码:
cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=OFF -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON USE_EIGEN=/usr/include/eigen3 ..
我的 OpenCV 代码包括以下标头和命名空间:
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <assert.h>
#include <opencv2/core/eigen.hpp>
using namespace cv;
using namespace std;
using namespace Eigen;
但是,当我通常编译 OpenCV 应用程序时,我的编译器给了我以下错误:
In file included from Read.cpp:6:
/usr/local/include/opencv2/core/eigen.hpp:54: error: expected ‘,’ or ‘...’ before ‘::’ token
/usr/local/include/opencv2/core/eigen.hpp: In function ‘void cv::eigen2cv(int)’:
/usr/local/include/opencv2/core/eigen.hpp:56: error: ‘src’ was not declared in this scope
/usr/local/include/opencv2/core/eigen.hpp:56: error: ‘Eigen’ is not a class or namespace
/usr/local/include/opencv2/core/eigen.hpp:60: error: ‘dst’ was not declared in this scope
/usr/local/include/opencv2/core/eigen.hpp:66: error: ‘dst’ was not declared in this scope
我该如何解决这个问题?