标签: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
标签:nbsp stream std 文件 tar 文件夹 忘记 tchar img
原文地址:http://www.cnblogs.com/ranjiewen/p/6063994.html