OpenCV+Visual Studio 2010、2012、2013、2015
来源:互联网 发布:传真服务器软件 编辑:程序博客网 时间:2024/06/15 16:07
1.download opencv 2.4.10,Unzip the package into a sub-directory
2.Modify director name
A. Modify directory build/x86 name vc10、vc11、vc12 as vc100、vc110、vc120,
B.Modify directory build/x64 name vc10、vc11、vc12 as vc100、vc110、vc120,
C. modify directory the x86 in build as win32
3.open your visual studio new a project
A
B
C
D
E
F
G
Then you can see the property manager :
A
Here may have a problem: only have debug|win32 and release|win32, have no x64,we need add debug|x64 and release|x64.
A
add debug|x64 and release|x64.
the result: we have debug|x64 and release|x64 now!
4. Add paths of header file and paths of library file :
A. Debug|Win32 Microsoft.Cpp.Win32.user
edit the include directories:
edit the library directories:H:\opencv2.4.10\build/$(Platform)/vc$(PlatformToolsetVersion)/staticlib
B.do the same thing to 2、3、4 as step A,add the same paths of header file and same paths of library file
5.add macro definition:_CRT_SECURE_NO_WARNINGS
A
B . also same to 2、3、4
6. write program
Write in code:
#include "stdafx.h"#include <cv.h>#include <opencv2/core/core.hpp>#include <highgui.h>using namespace cv;int _tmain(int argc, _TCHAR* argv[]){ Mat img(300, 300, CV_8UC3); img.setTo(Scalar(0, 255)); imshow("Hello OpenCV", img); waitKey(); return 0;}
a.open cv.h
b.add #include <opencv/cv_import_static_lib.h> in cv.h
c.open core.hpp
d.add #include <opencv/cv_import_static_lib.h> in core.hpp
e. core.hpp right click ,open core.hpp containing floder 。Go to directory:H:\opencv2.4.10\build\include\opencv
f new txt file add the following content and save
#pragma once#ifdef WIN32#include <opencv2/core/version.hpp>//定义宏,保证在debug模式下,导入opencv_xxxd.lib,release模式下导入opencv_xxx.lib#ifdef _DEBUG# define CC_CVLIB(name) "opencv_" name CC_CVVERSION_ID "d.lib"# define CC_CVLIB_2(name) "opencv_" name CC_CVVERSION_ID2 "d.lib"# define CC_LIB(name) name "d.lib"#else# define CC_CVLIB(name) "opencv_" name CC_CVVERSION_ID ".lib"# define CC_CVLIB_2(name) "opencv_" name CC_CVVERSION_ID2 ".lib"# define CC_LIB(name) name ".lib"#endif//对于静态库,必须导入如下这些库#pragma comment(lib, "kernel32.lib")#pragma comment(lib, "user32.lib")#pragma comment(lib, "gdi32.lib")#pragma comment(lib, "Vfw32.lib")#pragma comment(lib, "winspool.lib")#pragma comment(lib, "comdlg32.lib")#pragma comment(lib, "advapi32.lib")#pragma comment(lib, "shell32.lib")#pragma comment(lib, "ole32.lib")#pragma comment(lib, "oleaut32.lib")#pragma comment(lib, "uuid.lib")#pragma comment(lib, "odbc32.lib")#pragma comment(lib, "odbccp32.lib")#pragma comment(lib, "Comctl32.lib")//如果为3版,导入方式不同#if CV_MAJOR_VERSION==3//定义cv的库名称,2410版的,如果是其他版本,则修改为指定的就好了#define CC_CVVERSION_ID "2410"#define CC_CVVERSION_ID2 "300"//导入静态库依赖#pragma comment(lib, CC_LIB("IlmImf"))#pragma comment(lib, CC_LIB("libjasper"))#pragma comment(lib, CC_LIB("libjpeg"))#pragma comment(lib, CC_LIB("libpng"))#pragma comment(lib, CC_LIB("libtiff"))#pragma comment(lib, CC_LIB("libwebp"))#pragma comment(lib, "ippicvmt.lib")#pragma comment( lib, CC_CVLIB("calib3d") )#pragma comment( lib, CC_CVLIB_2("calib3d") )#pragma comment( lib, CC_CVLIB("contrib") )//#pragma comment( lib, CC_CVLIB("core") )#pragma comment( lib, CC_CVLIB_2("core") )//#pragma comment( lib, CC_CVLIB("core") )#pragma comment( lib, CC_CVLIB_2("features2d") )#pragma comment( lib, CC_CVLIB("features2d") )#pragma comment( lib, CC_CVLIB_2("flann") )#pragma comment( lib, CC_CVLIB("flann") )#pragma comment( lib, CC_CVLIB("gpu") )#pragma comment( lib, CC_CVLIB_2("highgui") )#pragma comment( lib, CC_CVLIB("highgui") )#pragma comment( lib, CC_CVLIB_2("imgcodecs") )#pragma comment( lib, CC_CVLIB_2("imgproc") )#pragma comment( lib, CC_CVLIB("imgproc") )#pragma comment( lib, CC_CVLIB("legacy") )#pragma comment( lib, CC_CVLIB_2("ml") )#pragma comment( lib, CC_CVLIB("ml") )#pragma comment( lib, CC_CVLIB("ocl") )#pragma comment( lib, CC_CVLIB("nonfree") )#pragma comment( lib, CC_CVLIB_2("objdetect") )#pragma comment( lib, CC_CVLIB("objdetect") )#pragma comment( lib, CC_CVLIB_2("photo") )#pragma comment( lib, CC_CVLIB("photo") )#pragma comment( lib, CC_CVLIB_2("shape") )#pragma comment( lib, CC_CVLIB_2("stitching") )#pragma comment( lib, CC_CVLIB("stitching") )#pragma comment( lib, CC_CVLIB_2("superres") )#pragma comment( lib, CC_CVLIB("superres") )#pragma comment( lib, CC_CVLIB_2("ts") )#pragma comment( lib, CC_CVLIB("ts") )#pragma comment( lib, CC_CVLIB_2("video") )#pragma comment( lib, CC_CVLIB("video") )#pragma comment( lib, CC_CVLIB_2("videoio") )#pragma comment( lib, CC_CVLIB_2("videostab") )#pragma comment( lib, CC_CVLIB("videostab") )#pragma comment(lib, CC_LIB("zlib"))#else#define CC_CVVERSION_ID CVAUX_STR(CV_VERSION_EPOCH) CVAUX_STR(CV_VERSION_MAJOR) CVAUX_STR(CV_VERSION_MINOR)//导入静态库依赖#pragma comment(lib, CC_LIB("IlmImf"))#pragma comment(lib, CC_LIB("libjasper"))#pragma comment(lib, CC_LIB("libjpeg"))#pragma comment(lib, CC_LIB("libpng"))#pragma comment(lib, CC_LIB("libtiff"))#pragma comment( lib, CC_CVLIB("calib3d") )#pragma comment( lib, CC_CVLIB("contrib") )#pragma comment( lib, CC_CVLIB("core") )#pragma comment( lib, CC_CVLIB("features2d") )#pragma comment( lib, CC_CVLIB("flann") )#pragma comment( lib, CC_CVLIB("gpu") )#pragma comment( lib, CC_CVLIB("highgui") )#pragma comment( lib, CC_CVLIB("imgproc") )#pragma comment( lib, CC_CVLIB("legacy") )#pragma comment( lib, CC_CVLIB("ml") )#pragma comment( lib, CC_CVLIB("ocl") )#pragma comment( lib, CC_CVLIB("nonfree") )#pragma comment( lib, CC_CVLIB("objdetect") )#pragma comment( lib, CC_CVLIB("photo") )#pragma comment( lib, CC_CVLIB("stitching") )#pragma comment( lib, CC_CVLIB("superres") )#pragma comment( lib, CC_CVLIB("ts") )#pragma comment( lib, CC_CVLIB("video") )#pragma comment( lib, CC_CVLIB("videostab") )#pragma comment(lib, CC_LIB("zlib"))#endif //CV_MAJOR_VERSION#endif
g.modify the .txt file name as import_static_lib.h
h.back to the project ,
run codes:
it‘s ok now
notes:
if you want to Play video file,you must add the files:opencv_ffmpeg2410.dll and opencv_ffmpeg2410_64.dll to c:/windows/system32
- OpenCV+Visual Studio 2010、2012、2013、2015
- OpenCV环境配置Visual Studio 2010、2012、2013、2015
- OpenCV环境配置Visual Studio 2010、2012、2013、2015
- OpenCV 2.3.x/2.4.x在Visual Studio 2005/2008、Visual Studio 2010和Visual Studio 2012配置方法详解
- OpenCV 2.3.x/2.4.x在Visual Studio 2005/2008、Visual Studio 2010和Visual Studio 2012配置方法详解
- OpenCV 2.3.x/2.4.x在Visual Studio 2005/2008、Visual Studio 2010和Visual Studio 2012配置方法详解
- OpenCV 2.1.0 with Visual Studio 2010
- visual studio 2010 建立 OpenCV 2.4 环境
- 在Visual Studio 2010中使用opencv
- opencv 与visual studio 2008/2010 配置
- opencv入门03(visual studio 2010)--20160103
- OpenCV配置Visual Studio 2010具体步骤
- [OpenCV]:Visual Studio 2012 搭建 OpenCV2.4.3
- opencv在visual studio 2012的配置
- 安装visual studio 2012,并配置opencv
- Visual Studio 2012配置opencv 2.4.11
- Building OpenCV with Visual Studio 2015
- Visual Studio 2015配置opencv开发环境
- MySQL的deocode,与not in的关联查询实现
- UEFI+GPT+KDE5+archlinux安装教程(自用)
- poj 3468 线段树区间更新
- hdu2579 Dating with girls(2)--BFS
- CodeForces 616A Comparing Two Long Integers
- OpenCV+Visual Studio 2010、2012、2013、2015
- java基础学习(7)浅析final,private,public,protected,static等关键以及它们的区别的联系
- C++中的句柄
- [HDU 5729] Rigid Frameworks (二分图联通方案计数)
- maven启动 cannot be cast to javax.servlet.Filter/cannot be cast to javax.servlet.Servlet 报错
- java.lang.IllegalArgumentException: invalid comparison: java.util.Date and java.lang.String
- 极角排序合集
- 简单dp算法——百炼05:切割回文
- 类之间的关系