繁体   English   中英

将Eigen库与OpenCV 2.3.1一起使用

[英]Using Eigen Library with OpenCV 2.3.1

我在使用Eigen3库和C ++中的 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

我该如何解决这个问题?

我只需要包括

#include <Eigen/Dense>

在包括OpenCV标头多数民众赞成之前。 我通过包含Eigen lib头文件和OpenCV lib头文件来编译它们。

首先,我将再次检查是否找到了特征包含方向。 您可以使用CMakeList.txt来执行此操作(并且您应该使用cmake函数来查找标头并链接到库,而不是编译器标志)

接下来,您可以尝试删除using命名空间

    using namespace cv;
    using namespace std;
    using namespace Eigen;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM