使用特征库与OpenCV 2.3.1

gar*_*rak 8 c++ opencv eigen

我在使用Eigen3库和C++中的OpenCV应用程序时遇到了麻烦.我使用以下命令在我的Ubuntu上安装了Eigen3库:

sudo apt-get install libeigen3-dev
Run Code Online (Sandbox Code Playgroud)

当我使用以下命令进行编译时,我能够编译和使用示例Eigen3应用程序(安装Eigen3库并且它可以工作).

g++ -I/usr/include/eigen3 Eig.cpp -o Eig
Run Code Online (Sandbox Code Playgroud)

我想在OpenCV中使用已安装的Eigen库.

我用以下标志编译了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 ..
Run Code Online (Sandbox Code Playgroud)

我的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;
Run Code Online (Sandbox Code Playgroud)

但是,当我正常编译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
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

gar*_*rak 9

我只需要包括在内

#include <Eigen/Dense>
Run Code Online (Sandbox Code Playgroud)

在包括所有OpenCV标题之前.我通过包含Eigen lib头和OpenCV lib头来编译它们.