腾讯微群加入QQ群

 找回密码
 加入我们

!connect_header_login!

!connect_header_login_tip!

搜索
查看: 296|回复: 0

win10+vs2015+opencv3.0

[复制链接]
发表于 2016-8-23 13:26:40 | 显示全部楼层 |阅读模式

win10+vs2015+opencv3.0

此文简单记录配置过程

1 准备资源

下载opencv-for-windows:http://opencv.org/downloads.html

2 安装

运行 opencv-3.0.0.exe,实际上这是个压缩文件,将文件解压到磁盘。

3 配置与测试

1) 配置环境变量

打开 此电脑->右键->属性->高级系统设置->环境变量->新建,如下图
这里写图片描述

在path中添加opencv的可执行文件路径,如下图
这里写图片描述
PS:最好不要在末尾添加分号“;”

3) 编写vs2015的属性表文件

编写如下的属性表文件,保存为:opencv300.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>$(OPENCV)\include;$(IncludePath)</IncludePath>
    <LibraryPath Condition="'$(Platform)'=='Win32'">$(OPENCV)\x86\vc12\lib;$(OPENCV)\x86\vc12\staticlib;$(LibraryPath)</LibraryPath>
    <LibraryPath Condition="'$(Platform)'=='X64'">$(OPENCV)\x64\vc12\lib;$(OPENCV)\x64\vc12\staticlib;$(LibraryPath)</LibraryPath>
  </PropertyGroup>
  <ItemDefinitionGroup>
    <Link Condition="'$(Configuration)'=='Debug'">
      <AdditionalDependencies>opencv_ts300d.lib;opencv_world300d.lib;IlmImfd.lib;libjasperd.lib;libjpegd.lib;libpngd.lib;libtiffd.lib;libwebpd.lib;opencv_calib3d300d.lib;opencv_core300d.lib;opencv_features2d300d.lib;opencv_flann300d.lib;opencv_highgui300d.lib;opencv_imgcodecs300d.lib;opencv_imgproc300d.lib;opencv_ml300d.lib;opencv_objdetect300d.lib;opencv_photo300d.lib;opencv_shape300d.lib;opencv_stitching300d.lib;opencv_superres300d.lib;opencv_video300d.lib;opencv_videoio300d.lib;opencv_videostab300d.lib;zlibd.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
    <Link Condition="'$(Configuration)'=='Release'">
      <AdditionalDependencies>opencv_ts300.lib;opencv_world300.lib;IlmImf.lib;ippicvmt.lib;libjasper.lib;libjpeg.lib;libpng.lib;libtiff.lib;libwebp.lib;opencv_calib3d300.lib;opencv_core300.lib;opencv_features2d300.lib;opencv_flann300.lib;opencv_highgui300.lib;opencv_imgcodecs300.lib;opencv_imgproc300.lib;opencv_ml300.lib;opencv_objdetect300.lib;opencv_photo300.lib;opencv_shape300.lib;opencv_stitching300.lib;opencv_superres300.lib;opencv_video300.lib;opencv_videoio300.lib;opencv_videostab300.lib;zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <ItemGroup />
</Project>

4) 编写测试代码

新建win32控制台应用程序,测试代码如下

// ConsoleApplication1.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <opencv2/opencv.hpp>
#include <iostream>
#include <string>

using namespace cv;
using namespace std;

int main()
{
    Mat image = imread("figure.bmp");
    if (image.empty())
    {
        cout << "error" << endl;
        return -1;
    }
    imshow("Image", image);
    waitKey();
    return 0;
}

5) 添加属性列表

打开vs2015的 视图->其他窗口->属性管理器,然后选定当前的工程,右键->添加现有属性表,选择第 3)步编写的属性表文件,如下图
这里写图片描述

6) 运行程序

编译运行刚才的程序,看是否成功。

本人在运行过程中,系统报错,说是缺少dll库的支持,分别是msvcr120d.dll和msvcp120d.dll,上网搜索下载缺少的动态链接库,放到指定的位置即可。

1
0

转自:http://blog.csdn.net/wdsky2010/article/details/47262975?locationNum=2
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

QQ|手机版|Archiver|小黑屋|一起疯|苦咖啡 ( 新ICP备12000197号  

GMT+8, 2017-12-12 16:43 , Processed in 4.530044 second(s), 12 queries , Memcache On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表