OpenCV標頭檔包含問題

來源:互聯網
上載者:User

標籤:nbsp   stream   std   檔案   tar   檔案夾   忘記   tchar   img   

     opencv從2.2版本以後<opencv root>include下有兩個檔案夾 opencv 和opencv2。從官方的意思來看,它逐漸喜歡用opencv2裡面的那種包含標頭檔的方式。

注意:<opencv root>是opencv2.2安裝路徑。每個人的路徑都可能有所不同!!

Opencv.hpp本身是一個標頭檔,它包含了opencv全部的標頭檔。有圖有真相:

#ifndef __OPENCV_ALL_HPP__    #define __OPENCV_ALL_HPP__    #include "opencv2/core/core_c.h"    #include "opencv2/core/core.hpp"    #include "opencv2/flann/flann.hpp"    #include "opencv2/imgproc/imgproc_c.h"    #include "opencv2/imgproc/imgproc.hpp"    #include "opencv2/video/tracking.hpp"    #include "opencv2/video/background_segm.hpp"    #include "opencv2/features2d/features2d.hpp"    #include "opencv2/objdetect/objdetect.hpp"    #include "opencv2/calib3d/calib3d.hpp"    #include "opencv2/ml/ml.hpp"    #include "opencv2/highgui/highgui_c.h"    #include "opencv2/highgui/highgui.hpp"    #include "opencv2/contrib/contrib.hpp"    #endif  

 

    每次下載opencv的新版本時,都需要重新寫標頭檔,更改連結庫配置,很麻煩有木有?下面這個標頭檔是我在別人的代碼中淘出來的,很不錯,與大家分享~(具體作者忘記了,不好意思啊)

  作者很巧妙地利用Opencv的版本資訊定義了一個宏,無論你的Opencv是243還是246都能夠完美支援,以後再不用擔心更新版本帶來的問題了,另:對於比較老的Opencv版本可能有個別lib的名稱不對,修改一下就可以了

#pragma once#include "targetver.h"#include <stdio.h>#include <tchar.h>#include <iostream>#include <fstream>#include <opencv2/opencv.hpp>#define CV_VERSION_ID       CVAUX_STR(CV_MAJOR_VERSION) CVAUX_STR(CV_MINOR_VERSION) CVAUX_STR(CV_SUBMINOR_VERSION)#ifdef _DEBUG#define cvLIB(name) "opencv_" name CV_VERSION_ID "d"#else#define cvLIB(name) "opencv_" name CV_VERSION_ID#endif#pragma comment( lib, cvLIB("core") )#pragma comment( lib, cvLIB("imgproc") )#pragma comment( lib, cvLIB("highgui") )#pragma comment( lib, cvLIB("flann") )#pragma comment( lib, cvLIB("features2d") )#pragma comment( lib, cvLIB("calib3d") )#pragma comment( lib, cvLIB("gpu") )#pragma comment( lib, cvLIB("legacy") )#pragma comment( lib, cvLIB("ml") )#pragma comment( lib, cvLIB("objdetect") )#pragma comment( lib, cvLIB("ts") )#pragma comment( lib, cvLIB("video") )#pragma comment( lib, cvLIB("contrib") )#pragma comment( lib, cvLIB("nonfree") )

 

version.hpp庫內建的:

#ifndef __OPENCV_VERSION_HPP__#define __OPENCV_VERSION_HPP__#define CV_VERSION_MAJOR    3#define CV_VERSION_MINOR    1#define CV_VERSION_REVISION 0#define CV_VERSION_STATUS   ""#define CVAUX_STR_EXP(__A)  #__A#define CVAUX_STR(__A)      CVAUX_STR_EXP(__A)#define CVAUX_STRW_EXP(__A)  L#__A#define CVAUX_STRW(__A)      CVAUX_STRW_EXP(__A)#define CV_VERSION          CVAUX_STR(CV_VERSION_MAJOR) "." CVAUX_STR(CV_VERSION_MINOR) "." CVAUX_STR(CV_VERSION_REVISION) CV_VERSION_STATUS/* old  style version constants*/#define CV_MAJOR_VERSION    CV_VERSION_MAJOR#define CV_MINOR_VERSION    CV_VERSION_MINOR#define CV_SUBMINOR_VERSION CV_VERSION_REVISION#endif

 

OpenCV標頭檔包含問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.