openCV vs2013配置

让曾经也是小白的我来写一个VS一次配置永久使用OpenCV终极小白教程:

说白了就是将VS第一次配置OpenCV的项目属性表保存下来,每次新建项目时引用即可。


目录

  1. 解压OpenCV

  2. 配置系统环境变量

  3. 创建VS新项目

  4. 添加项目属性表

  5. 配置项目属性表

  6. 引用项目属性表



声明:

  1. 以下展示内容,配置方案为OpenCV2.4.9+VS2013+win10+x64,但方法适用于OpenCV2.4.8、OpenCV2.4.9、OpenCV2.4.10,适用于win7、win8.1、win10,适用于x64和x84(下面会讲解如何对应修改)。如果问为什么适用?因为我都试过啊~

  2. 会一次性配置的知友请直接看第四部分和第六部分,因为其余部分跟一次性配置是一样的。


一、解压OpenCV
比如本人解压在G盘根目录下

650) this.width=650;" src="https://pic1.zhimg.com/d6135179281f46ce18ff9a6209d380d0_b.png" class="origin_image zh-lightbox-thumb" alt="d6135179281f46ce18ff9a6209d380d0_b.png" width="821" />650) this.width=650;" style="width:584px;height:379.849px;" src="https://pic1.zhimg.com/d6135179281f46ce18ff9a6209d380d0_b.png" class="origin_image zh-lightbox-thumb lazy" alt="d6135179281f46ce18ff9a6209d380d0_b.png" width="821" />

二、配置系统环境变量

打开“系统属性”,点击“环境变量”
650) this.width=650;" src="https://pic1.zhimg.com/d470fcfbc0bac0f7169574a144951dbc_b.png" class="origin_image zh-lightbox-thumb" alt="d470fcfbc0bac0f7169574a144951dbc_b.png" width="476" />650) this.width=650;" style="width:476px;height:598px;" src="https://pic1.zhimg.com/d470fcfbc0bac0f7169574a144951dbc_b.png" class="origin_image zh-lightbox-thumb lazy" alt="d470fcfbc0bac0f7169574a144951dbc_b.png" width="476" />
双击Path的值部分
650) this.width=650;" src="https://pic3.zhimg.com/f7d668ca7ff2646e6189b2d43f899c9a_b.png" class="origin_image zh-lightbox-thumb" alt="f7d668ca7ff2646e6189b2d43f899c9a_b.png" width="445" />650) this.width=650;" style="width:445px;height:560px;" src="https://pic3.zhimg.com/f7d668ca7ff2646e6189b2d43f899c9a_b.png" class="origin_image zh-lightbox-thumb lazy" alt="f7d668ca7ff2646e6189b2d43f899c9a_b.png" width="445" />
填上OpenCV的bin路径
650) this.width=650;" src="https://pic2.zhimg.com/c02b13011b23eead03bc7e944bb7d7e9_b.png" class="origin_image zh-lightbox-thumb" alt="c02b13011b23eead03bc7e944bb7d7e9_b.png" width="651" />650) this.width=650;" style="width:584px;height:162.372px;" src="https://pic2.zhimg.com/c02b13011b23eead03bc7e944bb7d7e9_b.png" class="origin_image zh-lightbox-thumb lazy" alt="c02b13011b23eead03bc7e944bb7d7e9_b.png" width="651" />
注意:
1、此时电脑最好重启下。
2、如果你电脑是x86,选择x86的路径;如果你电脑是x64,理论上选择x64的路径。
但是我x64的电脑选择x64的路径失败了,选择x84的路径却成功了,我也不知道为什么~
3、vc10, vc11, vc12 分别表示VS2010, VS2012, VS2013的Visual Studio使用的编译器版本,根据自己的VS版本来填写正确的编译器版本号。


三、创建VS新项目
650) this.width=650;" src="https://pic4.zhimg.com/7f15f6fc91c9b851f0260c8cd93f20ef_b.png" class="origin_image zh-lightbox-thumb" alt="7f15f6fc91c9b851f0260c8cd93f20ef_b.png" width="1200" />650) this.width=650;" style="width:584px;height:309.956px;" src="https://pic4.zhimg.com/7f15f6fc91c9b851f0260c8cd93f20ef_b.png" class="origin_image zh-lightbox-thumb lazy" alt="7f15f6fc91c9b851f0260c8cd93f20ef_b.png" width="1200" />650) this.width=650;" src="https://pic3.zhimg.com/d8f52c315f4a1f2f42624026d95fbd66_b.png" class="origin_image zh-lightbox-thumb" alt="d8f52c315f4a1f2f42624026d95fbd66_b.png" width="665" />650) this.width=650;" style="width:584px;height:425.047px;" src="https://pic3.zhimg.com/d8f52c315f4a1f2f42624026d95fbd66_b.png" class="origin_image zh-lightbox-thumb lazy" alt="d8f52c315f4a1f2f42624026d95fbd66_b.png" width="665" />650) this.width=650;" src="https://pic3.zhimg.com/6f8bce65bad6ea387ca404858b7fc55e_b.png" class="origin_image zh-lightbox-thumb" alt="6f8bce65bad6ea387ca404858b7fc55e_b.png" width="665" />650) this.width=650;" style="width:584px;height:424.168px;" src="https://pic3.zhimg.com/6f8bce65bad6ea387ca404858b7fc55e_b.png" class="origin_image zh-lightbox-thumb lazy" alt="6f8bce65bad6ea387ca404858b7fc55e_b.png" width="665" />

四、添加项目属性表

“视图”打开“属性窗口”
650) this.width=650;" src="https://pic2.zhimg.com/99070c1452bd971d6652d9b1c7f7c939_b.png" class="origin_image zh-lightbox-thumb" alt="99070c1452bd971d6652d9b1c7f7c939_b.png" width="461" />650) this.width=650;" style="width:461px;height:693px;" src="https://pic2.zhimg.com/99070c1452bd971d6652d9b1c7f7c939_b.png" class="origin_image zh-lightbox-thumb lazy" alt="99070c1452bd971d6652d9b1c7f7c939_b.png" width="461" />650) this.width=650;" src="https://pic2.zhimg.com/23b8967b62c6e5407d776d43e27b0ad5_b.png" class="content_image" alt="23b8967b62c6e5407d776d43e27b0ad5_b.png" width="346" />650) this.width=650;" style="width:346px;height:328px;" src="https://pic2.zhimg.com/23b8967b62c6e5407d776d43e27b0ad5_b.png" class="content_image lazy" alt="23b8967b62c6e5407d776d43e27b0ad5_b.png" width="346" />
右击“Debug|Win32”点击“添加新项目属性表”(如果想在Release模式下使用OpenCV,右击Release|Win32,同理可得)650) this.width=650;" src="https://pic2.zhimg.com/e83136838687ba83e81db9bbf4ede131_b.png" class="content_image" alt="e83136838687ba83e81db9bbf4ede131_b.png" width="351" />650) this.width=650;" style="width:351px;height:358px;" src="https://pic2.zhimg.com/e83136838687ba83e81db9bbf4ede131_b.png" class="content_image lazy" alt="e83136838687ba83e81db9bbf4ede131_b.png" width="351" />
给属性表命名
650) this.width=650;" src="https://pic2.zhimg.com/7aed98411d80eb2c9eb51c42fd21f4e1_b.png" class="origin_image zh-lightbox-thumb" alt="7aed98411d80eb2c9eb51c42fd21f4e1_b.png" width="937" />650) this.width=650;" style="width:584px;height:362.741px;" src="https://pic2.zhimg.com/7aed98411d80eb2c9eb51c42fd21f4e1_b.png" class="origin_image zh-lightbox-thumb lazy" alt="7aed98411d80eb2c9eb51c42fd21f4e1_b.png" width="937" />

五、配置项目属性表

双击创建的属性表
650) this.width=650;" src="https://pic1.zhimg.com/27db5dbe81b73a35f8579b2b70004b68_b.png" class="content_image" alt="27db5dbe81b73a35f8579b2b70004b68_b.png" width="346" />650) this.width=650;" style="width:346px;height:318px;" src="https://pic1.zhimg.com/27db5dbe81b73a35f8579b2b70004b68_b.png" class="content_image lazy" alt="27db5dbe81b73a35f8579b2b70004b68_b.png" width="346" />
5.1添加包含目录
650) this.width=650;" src="https://pic4.zhimg.com/7bc1ca5bb25dc0e38ef967d8ddb33c97_b.png" class="origin_image zh-lightbox-thumb" alt="7bc1ca5bb25dc0e38ef967d8ddb33c97_b.png" width="755" />650) this.width=650;" style="width:584px;height:346.532px;" src="https://pic4.zhimg.com/7bc1ca5bb25dc0e38ef967d8ddb33c97_b.png" class="origin_image zh-lightbox-thumb lazy" alt="7bc1ca5bb25dc0e38ef967d8ddb33c97_b.png" width="755" />650) this.width=650;" src="https://pic4.zhimg.com/93d0664f7307cf57a640398c5454b7f7_b.png" class="content_image" alt="93d0664f7307cf57a640398c5454b7f7_b.png" width="418" />650) this.width=650;" style="width:418px;height:397px;" src="https://pic4.zhimg.com/93d0664f7307cf57a640398c5454b7f7_b.png" class="content_image lazy" alt="93d0664f7307cf57a640398c5454b7f7_b.png" width="418" />
5.2添加附加库目录
650) this.width=650;" src="https://pic2.zhimg.com/be61e855039c30f20822fc95ee0919f9_b.png" class="origin_image zh-lightbox-thumb" alt="be61e855039c30f20822fc95ee0919f9_b.png" width="750" />650) this.width=650;" style="width:584px;height:349.621px;" src="https://pic2.zhimg.com/be61e855039c30f20822fc95ee0919f9_b.png" class="origin_image zh-lightbox-thumb lazy" alt="be61e855039c30f20822fc95ee0919f9_b.png" width="750" />650) this.width=650;" src="https://pic3.zhimg.com/55abca94d7eae1b35ac9cc5124bce092_b.png" class="content_image" alt="55abca94d7eae1b35ac9cc5124bce092_b.png" width="418" />650) this.width=650;" style="width:418px;height:397px;" src="https://pic3.zhimg.com/55abca94d7eae1b35ac9cc5124bce092_b.png" class="content_image lazy" alt="55abca94d7eae1b35ac9cc5124bce092_b.png" width="418" />
注意:
1、如果你电脑是x86,选择x86的路径;如果你电脑是x64,理论上选择x64的路径。但是我x64的电脑选择x64的路径失败了,选择x84的路径却成功了,我也不知道为什么~
2、vc10, vc11, vc12 分别表示VS2010, VS2012, VS2013的Visual Studio使用的编译器版本,根据自己的VS版本来填写正确的编译器版本号。

5.3添加附加依赖项

附加依赖项如下:
opencv_imgproc249d.lib
opencv_calib3d249d.lib
opencv_contrib249d.lib
opencv_core249d.lib
opencv_features2d249d.lib
opencv_flann249d.lib
opencv_gpu249d.lib
opencv_highgui249d.lib
opencv_legacy249d.lib
opencv_ml249d.lib
opencv_nonfree249d.lib
opencv_objdetect249d.lib
opencv_ocl249d.lib
opencv_photo249d.lib
opencv_stitching249d.lib
opencv_superres249d.lib
opencv_ts249d.lib
opencv_video249d.lib
opencv_videostab249d.lib

注意:
1、249对应OpenCV2.4.9,其他版本做对应修改。
2、后缀d代表Debug模式,如果是Release模式去掉d。依个人情况选择Debug模式或者Release模式。

650) this.width=650;" src="https://pic3.zhimg.com/38daa2039c439378a5289b447b98725e_b.png" class="origin_image zh-lightbox-thumb" alt="38daa2039c439378a5289b447b98725e_b.png" width="753" />650) this.width=650;" style="width:584px;height:349.78px;" src="https://pic3.zhimg.com/38daa2039c439378a5289b447b98725e_b.png" class="origin_image zh-lightbox-thumb lazy" alt="38daa2039c439378a5289b447b98725e_b.png" width="753" />650) this.width=650;" src="https://pic3.zhimg.com/dbfdceec72dfc7038037de6aa7bb5e66_b.png" class="origin_image zh-lightbox-thumb" alt="dbfdceec72dfc7038037de6aa7bb5e66_b.png" width="422" />650) this.width=650;" style="width:422px;height:399px;" src="https://pic3.zhimg.com/dbfdceec72dfc7038037de6aa7bb5e66_b.png" class="origin_image zh-lightbox-thumb lazy" alt="dbfdceec72dfc7038037de6aa7bb5e66_b.png" width="422" />

六、引用项目属性表

打开项目目录,你会看到如下文件
650) this.width=650;" src="https://pic2.zhimg.com/fd97db6c52b4ce078b34489c08b79aa5_b.png" class="origin_image zh-lightbox-thumb" alt="fd97db6c52b4ce078b34489c08b79aa5_b.png" width="800" />650) this.width=650;" style="width:584px;height:236.52px;" src="https://pic2.zhimg.com/fd97db6c52b4ce078b34489c08b79aa5_b.png" class="origin_image zh-lightbox-thumb lazy" alt="fd97db6c52b4ce078b34489c08b79aa5_b.png" width="800" />

以后新建项目时,打开属性管理器,右击Debug|Win32选择添加现有属性表上述文件即可。


650) this.width=650;" src="https://pic3.zhimg.com/2c92811433387ccd5fa4a702f655171e_b.png" class="origin_image zh-lightbox-thumb" alt="2c92811433387ccd5fa4a702f655171e_b.png" width="523" />650) this.width=650;" style="width:523px;height:356px;" src="https://pic3.zhimg.com/2c92811433387ccd5fa4a702f655171e_b.png" class="origin_image zh-lightbox-thumb lazy" alt="2c92811433387ccd5fa4a702f655171e_b.png" width="523" />650) this.width=650;" src="https://pic2.zhimg.com/3fb1930f79f0172255ab0cdbb30b1edd_b.png" class="origin_image zh-lightbox-thumb" alt="3fb1930f79f0172255ab0cdbb30b1edd_b.png" width="670" />650) this.width=650;" style="width:584px;height:414.03px;" src="https://pic2.zhimg.com/3fb1930f79f0172255ab0cdbb30b1edd_b.png" class="origin_image zh-lightbox-thumb lazy" alt="3fb1930f79f0172255ab0cdbb30b1edd_b.png" width="670" />

========================

以上,应该算VS一次配置永久使用OpenCV了^ ^



作者:彭杰
链接:https://www.zhihu.com/question/24400428/answer/88284063
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


你可能感兴趣的:(随笔,其他,•)