文件名称:VS2010 + OpenCV2.4.3 + Windows Form Application
文件大小:4.79MB
文件格式:RAR
更新时间:2015-12-17 17:07:00
VS2010 OpenCV2.4.3 Windows
VS2010 + OpenCV2.4.3 + Windows Form Application
(注意:如需引用本文请征得本人许可!)
(原创)OpenCV在VS2010的Windows Form Application 的实现
以下为本人亲自验证过,含详细具体的安装编译及注意事项,完全可供参考!希望可以帮到OPENCV的爱好者(尤其是新兵)少走弯路.如需源码可邮件询索(后附).
VS2010 + OpenCV2.4.3
====================================================
一.OpenCV的编译安装:
1.解压OpenCV-2.4.3.exe -> D:/OpenCV/Resources/OpenCV-2.4.3/opencv
2.运行CMake...为VS编译...
Where is the source code(源码): D:/OpenCV/Resources/OpenCV-2.4.3/opencv
Where is build the binaries(目标): D:/OpenCV/Resources/OpenCV-2.4.3/opencv/vs2010
Configure: 选择 Visual Studio 10/?
Generate: 生成目标
3.打开D:/OpenCV/Resources/OpenCV-2.4.3/opencv/vs2010,用对应版本的VS打开OpenCV.sln...
A.编译OpenCV方案Debug版本:
1,编译OpenCV方案(Debug): 在VS工作区界面左侧方案浏览器(Solution Explorer)中选中最顶项方案"Solution 'OpenCV' (61 projects)",确定Solution Configure为Debug,右键执行Build Soluton(编译方案);
2,编译ALL_BUILD项目(Debug): 在VS工作区界面左侧方案浏览器(Solution Explorer)列表中选中项目"ALL_BUILD",确定Solution Configure为Debug,右键执行Build(编译项目);
3,编译CMakeTargets\INSTALL项目(Debug): 在VS工作区界面左侧方案浏览器(Solution Explorer)列表中选中"CMakeTargets\INSTALL"项目,确定Solution Configure为Debug,右键执行Build(编译项目);
B.编译OpenCV方案Release版本:
1,编译OpenCV方案(Release): 在VS工作区界面左侧方案浏览器(Solution Explorer)中选中最顶项方案"Solution 'OpenCV' (61 projects)",确定Solution Configure为Release,右键执行Build Soluton(编译方案);
2,编译ALL_BUILD项目(Release): 在VS工作区界面左侧方案浏览器(Solution Explorer)列表中选中项目"ALL_BUILD",确定Solution Configure为Release,右键执行Build(编译项目);
3,编译CMakeTargets\INSTALL项目(Release): 在VS工作区界面左侧方案浏览器(Solution Explorer)列表中选中"CMakeTargets\INSTALL"项目,确定Solution Configure为Release,右键执行Build(编译项目);
4.检查编译后的结果:
D:\OpenCV\Resources\OpenCV-2.4.3\opencv\vs2010\bin: 有Debug/Release两目录及相关文件资源;
D:\OpenCV\Resources\OpenCV-2.4.3\opencv\vs2010\lib: 有Debug/Release两目录及相关文件资源;
D:\OpenCV\Resources\OpenCV-2.4.3\opencv\vs2010\install: 有bin/include/lib三目录及相关文件资源;
其它可不要求
5.应用配置:
a.将编译好的目录D:\OpenCV\Resources\OpenCV-2.4.3\opencv\vs2010\install复制到C:\,并改名为C:\opencv;
b.增加OSXP系统变量Path: c:\opencv\bin (供OpenCV的exe应用程序调用);
c.增加OSXP系统变量OPENCV: 值为: C:\opencv;
---------------------------------------------
二.程序项目配置:
特别注意: 对项目属性的配置应注意Debug/Release两个版本各配置项的统一性,否则会引起可能的编译出错,如:Common Language Runtime Support(公共语言运行库支持): Common Language Runtime Support/(clr) (公共语言运行库支持(/clr)),否则将会导致编译出错!
6.VS应用(VS2010.控制台应用程序):
6.1,在VS项目属性中设置有下:
6.1.1,Configuration Properties(属性)/...
a, General(常规):
Use of MFC(MFC的使用): Use Standard Windows Libraries(使用标准 Windows 库)
Use of ATL(ALT的使用): Not Using ATL(不使用 ATL)
Common Language Runtime Support(公共语言运行库支持): No Common Language Runtime Support(无公共语言运行库支持,其它选项会出错)
b, C/C++/General:
Additonal Include Directories(附加包含目录): C:\opencv\include;c:\opencv\include\opencv;C:\opencv\include\opencv2 (可勾选Inherit from parent or project defaults(继承父级或项目默认值))
c, Linker/General:
Additonal Library Directories(附加库目录): C:\opencv\lib (可勾选Inherit from parent or project defaults(继承父级或项目默认值))
以上两项设置b,c(附加包含目录,附加库目录)均可在以下d等效替代等值设置:
d, (VS2005无此项)VC++ Directories:
Include Directories(包含目录): C:\opencv\include;c:\opencv\include\opencv;C:\opencv\include\opencv2 (可勾选Inherit from parent or project defaults(继承父级或项目默认值))
Library Directories(库目录): C:\opencv\lib (可勾选Inherit from parent or project defaults(继承父级或项目默认值))
e, Linker(链接器)/Input(输入)/Additional Libraries(附加依赖项):为项目属性引入库:
Release版本:...............
opencv_core243.lib
opencv_highgui243.lib
opencv_video243.lib
opencv_photo243.lib
opencv_calib3d243.lib
opencv_contrib243.lib
opencv_features2d243.lib
opencv_flann243.lib
opencv_gpu243.lib
opencv_imgproc243.lib
opencv_legacy243.lib
opencv_ml243.lib
opencv_nonfree243.lib
opencv_objdetect243.lib
opencv_stitching243.lib
opencv_ts243.lib
opencv_videostab243.lib
Debug版本...................
opencv_core243d.lib
opencv_highgui243d.lib
opencv_video243d.lib
opencv_photo243d.lib
opencv_calib3d243d.lib
opencv_contrib243d.lib
opencv_features2d243d.lib
opencv_flann243d.lib
opencv_gpu243d.lib
opencv_imgproc243d.lib
opencv_legacy243d.lib
opencv_ml243d.lib
opencv_nonfree243d.lib
opencv_objdetect243d.lib
opencv_stitching243d.lib
opencv_ts243d.lib
opencv_videostab243d.lib
6.2,在VS项目源码包含引用:
//可用...
#include
【文件预览】:
cvwin2010
----cvwin2010()
--------app.ico(1KB)
--------resource.h(91B)
--------app.rc(2KB)
--------cvwin2010.vcxproj.user(143B)
--------Debug()
--------stdafx.h(242B)
--------ReadMe.txt(2KB)
--------FrmMain.resX(6KB)
--------Release()
--------stdafx.cpp(209B)
--------cvwin2010.vcxproj.filters(2KB)
--------AssemblyInfo.cpp(1KB)
--------FrmMain.h(3KB)
--------cvwin2010.vcxproj(6KB)
--------cvwin2010.cpp(442B)
----cvwin2010.sdf(12.89MB)
----Debug()
--------cvwin2010.exe(124KB)
--------cvwin2010.pdb(1.35MB)
--------cvwin2010.ilk(0B)
----opencv.jpg(6KB)
----cvwin2010.txt(3KB)
----Release()
--------cvwin2010.exe(112KB)
--------cvwin2010.pdb(1.31MB)
----cvwin2010.sln(894B)
----cvwin2010.suo(14KB)