将Eigen库与OpenCV 2.3.1一起使用 [英] Using Eigen Library with OpenCV 2.3.1
问题描述
我在使用 C ++ 中的 Eigen3 库和 OpenCV 应用程序时遇到麻烦. 我已经使用以下命令在Ubuntu上安装了Eigen3库:
I have trouble in using Eigen3 Library along with OpenCV application in C++. I have installed Eigen3 library on my Ubuntu using the following command:
sudo apt-get install libeigen3-dev
使用以下命令进行编译时,我能够编译并使用 Eigen3示例应用程序(已安装Eigen3库,并且可以正常工作).
I am able to compile and use sample Eigen3 applications (Eigen3 library is installed and it works) when I use the following command to compile.
g++ -I/usr/include/eigen3 Eig.cpp -o Eig
我想将已安装的Eigen库与OpenCV一起使用.
I want to use the installed Eigen library with OpenCV.
我用以下标志编译了OpenCV源代码:
I compiled OpenCV source with following flags:
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代码包括以下标头和名称空间:
My OpenCV code includes the following headers and namespace:
#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
我该如何解决这个问题?
How do I solve this problem?
推荐答案
我只需要包含
#include <Eigen/Dense>
包括OpenCV标头没错.我通过包含Eigen lib头文件和OpenCV lib头文件来编译它们.
before including OpenCV headers thats all. I compiled them by including the Eigen lib headers and OpenCV lib headers.
这篇关于将Eigen库与OpenCV 2.3.1一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!