c++ - 在 OpenCV 2.3.1 中使用特征库

标签 c++ opencv eigen

我在 C++ 中使用 Eigen3 库和 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 代码包含以下 header 和命名空间:

#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 header 之前就是这样。我通过包含 Eigen 库 header 和 OpenCV 库 header 来编译它们。

关于c++ - 在 OpenCV 2.3.1 中使用特征库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9876209/

相关文章:

c++ - 使用 Opencv C++ 中对象的给定 X、Y 进行卡尔曼滤波器跟踪

python - 如何在不影响图像其余部分的情况下删除图像中的外圈?

c++ - 将 Eigen 数组行保存在变量中

c++ - 通过模板发布 C++ Eigen::Matrix 类型

java - 我不明白 return 在编程中的作用是什么?

c++ - 如何编写我自己的操纵器?

c++ - 在 C++ 的命名空间中使用函数名?

c++ - 如何用OpenCV绘制圆角矩形(带圆角的矩形)?

c++ - 特征张量问题 : Conflicting declaration

c++ - 我可以在调用纯虚函数时禁用异常吗?