码迷,mamicode.com
首页 > Windows程序 > 详细

Win7+VS2017+OpenCV3.4.2无痛安装,Win10应该也差不多

时间:2018-07-19 11:55:42      阅读:1016      评论:0      收藏:0      [点我收藏+]

标签:tin   general   rmq   github   tool   装包   orm   win   输入   

 

安装VS2017

  1. 在微软官网https://www.microsoft.com,下载Visual Studio 2017安装包
  2. 用管理员权限运行vs2017 enterprise安装包,安装过程会持续1~2个小时。
  3. 注册激活:
    1. Enterprise: NJVYC-BMHX2-G77MM-4XJMR-6Q8QF
    2. Professional:  

      KBJFW-NXHK6-W4WJM-CRMQB-G3CDH

  4. 测试安装结果:启动VS2017,新建工程,并编译运行。

安装OpenCV3.4

  1. 在github官方仓库https://github.com/opencv/opencv/releases,下载OpenCV3.4.2
  2. 安装(解压)到C:\
  3. 配置OpenCV环境变量:
    1. 右键Computer -> Properties -> Advanced system settings -> Environment variables
    2. System variables -> New -> 输入OPENCV和目录C:\opencv\build
    3. System variables -> Path -> 添加%OPENCV%\x64\vc15\bin;

配置VS2017工程+案例测试

  1. 新建工程取名test
  2. 配置OpenCV库,View -> Other Window -> Property Manager,选中Debug|x64 -> Microsoft.Cpp.x64.user -> Properties
    1. VC++ Directories -> Include Directories -> 添加C:\opencv\build\include
    2. VC++ Directories -> Library Directories -> 添加C:\opencv\build\x64\vc15\lib
    3. Linker -> Input -> Additional Dependencies -> 添加opencv_world342d.lib
  3. 编辑代码
    #include<iostream>
    #include <opencv2/opencv.hpp>
    using namespace cv;
    
    int main()
    {
        Mat img = imread("test_image.jpg"); // 读入一张图片,图片与test.cpp同一目录
        namedWindow("test_image", cv::WINDOW_NORMAL); // 创建一个名为 "test_image" 的窗口
        imshow("test_image", img); // 在窗口中显示
        waitKey();
    
        return 0;
    }
  4. 编译运行,提示an error has occurred in the script on this page  expected identifier string or number,解决办法:
    1. Debug -> Debugging -> General ->  取消Enable Diagnostic Tools while debugging -> OK保存
    2. 重启VS2017,已解决

技术分享图片

 

Win7+VS2017+OpenCV3.4.2无痛安装,Win10应该也差不多

标签:tin   general   rmq   github   tool   装包   orm   win   输入   

原文地址:https://www.cnblogs.com/xbit/p/9328066.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!