Visual Studio 2013+OpenCV2.4.10环境搭建教程
程序员文章站
2022-07-05 20:14:49
opencv是一个使用起来非常方便的开放视觉库。本文详细讲解如何在win8.1+visual studio 2013环境下配置opencv2.4.10
工具:opencv...
opencv是一个使用起来非常方便的开放视觉库。本文详细讲解如何在win8.1+visual studio 2013环境下配置opencv2.4.10
工具:opencv2.4.10
方法/步骤:
这里用的opencv版本是2.4.10,可以在opencv的官网上免费下载。软件大小约为350m。
下载完毕后,双击打开“opencv-2.4.10”,选择解压目录。我这里选择解压目录为d盘。确认解压目录后,点击“extract“。解压完成后,在opencv文件夹中生成两个文件夹。
配置环境变量,这里用的是win8.1专业版。控制面板-系统和安全-系统-高级系统设置,在打开的系统属性对话框中,选择”高级“,”环境变量“,在用户变量中点击”新建“,变量名:opencv,变量值:d:\opencv\build
在用户变量中选择“path”,在其末尾添值;d:\opencv\build\x86\vc12\bin(注意有分号)。到此环境变量配置完毕。重启电脑或注销电脑,使环境变量生效。
接下来在visual studio 2013进行配置。打开visual studio 2013,文件—新建—项目,选择"visula c++"—"win32控制台应用程序".(向导中选择空项目)
打开记事本,将以下内容保存成“opencvdebug.props”。
<?xml version="1.0" encoding="utf-8"?> <project toolsversion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <importgroup label="propertysheets" /> <propertygroup label="usermacros" /> <propertygroup> <includepath>d:\opencv\build\include;d:\opencv\build\include\opencv;d:\opencv\build\include\opencv2;$(includepath)</includepath> <librarypath>d:\opencv\build\x86\vc12\lib;$(librarypath)</librarypath> </propertygroup> <itemdefinitiongroup> <link> <additionaldependencies>opencv_ml2410d.lib;opencv_calib3d2410d.lib;opencv_contrib2410d.lib;opencv_core2410d.lib;opencv_features2d2410d.lib;opencv_flann2410d.lib;opencv_gpu2410d.lib;opencv_highgui2410d.lib;opencv_imgproc2410d.lib;opencv_legacy2410d.lib;opencv_objdetect2410d.lib;opencv_ts2410d.lib;opencv_video2410d.lib;opencv_nonfree2410d.lib;opencv_ocl2410d.lib;opencv_photo2410d.lib;opencv_stitching2410d.lib;opencv_superres2410d.lib;opencv_videostab2410d.lib;%(additionaldependencies)</additionaldependencies> </link> </itemdefinitiongroup> <itemgroup /> </project>
打开记事本,将以下内容保存成“opencvrelease.props”。
<?xml version="1.0" encoding="utf-8"?> <project toolsversion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <importgroup label="propertysheets" /> <propertygroup label="usermacros" /> <propertygroup> <includepath>d:\opencv\build\include;d:\opencv\build\include\opencv;d:\opencv\build\include\opencv2;$(includepath)</includepath> <librarypath>d:\opencv\build\x86\vc12\lib;$(librarypath)</librarypath> </propertygroup> <itemdefinitiongroup> <link> <additionaldependencies>opencv_objdetect2410.lib;opencv_ts2410.lib;opencv_video2410.lib;opencv_nonfree2410.lib;opencv_ocl2410.lib;opencv_photo2410.lib;opencv_stitching2410.lib;opencv_superres2410.lib;opencv_videostab2410.lib;opencv_calib3d2410.lib;opencv_contrib2410.lib;opencv_core2410.lib;opencv_features2d2410.lib;opencv_flann2410.lib;opencv_gpu2410.lib;opencv_highgui2410.lib;opencv_imgproc2410.lib;opencv_legacy2410.lib;opencv_ml2410.lib;%(additionaldependencies)</additionaldependencies> </link> </itemdefinitiongroup> <itemgroup /> </project>
在属性管理器中将之前保存的两个文件添加进去。到此配置完成。
在源文件中添加“源.cpp",并导入一张图片。在源文件中中输入一段代码测试。测试成功。
#include<cv.h> #include<highgui.h> int main(int argc, char** argv[]) { iplimage* src = cvloadimage("1.jpg",cv_load_image_grayscale); cvnamedwindow("src", cv_window_autosize); cvshowimage("src", src); cvwaitkey(0); cvreleaseimage(&src); cvdestroyallwindows(); return 0; }
end
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。