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

 

安装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。注意,此安装包是x64版本,用32位程序编译报错。
  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_world342.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,已解决
  5. 运行结果如下,图片来源于网络,如有侵权,请告知本人妥善处理。

 

转载于:https://www.cnblogs.com/xbit/p/9328066.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值