首页 技术 正文
技术 2022年11月14日
0 收藏 539 点赞 3,213 浏览 2371 个字

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
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,083
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,558
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,407
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,180
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,817
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,900