[英]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.