当前位置:网站首页>VS2019如何永久配置本地OpenCV4.5.5使用
VS2019如何永久配置本地OpenCV4.5.5使用
2022-07-01 06:20:00 【SteveDraw】
前言:
由于实际开发需求,需要将OpenCV原版(即C和C++编写的)生成.dll(动态链接库)供.Net的C#应用程序使用,因此需要新建一个C++空项目来生成.dll。也因此需要配置好VS工具和OpenCV间的连接,所以特地做个记录和经验分享,供大家参考!
环境:windows10专业版+vs2019+opencv4.5.5
一,下载和安装OpenCV
- 如果有需要,要指定对应详细版本的,建议去官网下载!
- 如果只是源代码浏览,可以去GitHub对应的仓库学习查看!
点击官网链接,下载好所需要使用的对应版本,但是这里值得注意的是,版本并不是乱选择的,要与您使用的VS版本对应才好!(与后面配置时有关联)下面给出参考对应版本(与最新为准,实际使用会有差别):
| VC版本号 | VS对应版本 |
|---|---|
| vc6 | VC6.0 |
| vc7 | VS2002 |
| vc7.1 | VS2003 |
| vc8 | VS2005 |
| vc9 | VS2008 |
| vc10 | VS2010 |
| vc11 | VS2012 |
| vc12 | VS2013 |
| vc13 | VS2014 |
| vc14 | VS2015 |
| vc15 | VS2017 |
| vc16 | VS2019 |

- 跳出如下界面后,会计时后自动下载文件(该版本大概200多m):

- 下载后,将安装文件打开,并在里面点击解压后,后便自动解压!

- 解压完成后,即可大功告成!

- 接着需要配置系统的环境变量,根据下面完成后依次点击确定就行,最好重启生效!

二,配置vs
- 在vs2019下,新建空项目:


- 点击视图->其他窗口->属性管理器

按如下所示,右键点击Microsoft.Cpp.x64.user,如果你没这个选择也很正常(上网问了下vs2019多数没这个,需要换成vs2017),但有个更快速便捷的方法:就是将Microsoft.Cpp.x64.user的电脑将相关配置文件复制粘贴到自己电脑上对应目录即可,找到目录“C:\Users\“你的用户名”\AppData\Local\Microsoft”,(一般情况下不显示AppData文件夹,需要在文件夹的查看选项中勾选“隐藏的项目”使其可见)。将下载好的文件MSBuild(点击下载)解压放到该文件目录下:



- 如果配置为Debug,选择opencv_world455d.lib
- 如果为Release,选择opencv_world455.lib


在demo.cpp文件下添加以下代码:
#include <opencv2/opencv.hpp>
#include "opencv2/imgcodecs/legacy/constants_c.h"
using namespace std;
using namespace cv;
void main(int argc, char* argv[]) {
//从文件中读入图像
Mat img = imread("D:\\Z-File\\cv\\1.jpg", 1);
Mat dst;
//如果读入图像失败
if (img.empty()) {
printf("打开图片失败!\n");
}
namedWindow("RGB", WINDOW_AUTOSIZE);
imshow("RGB", img);
cvtColor(img, dst, COLOR_BGR2GRAY);
namedWindow("GRAY", WINDOW_AUTOSIZE);
imshow("GRAY", dst);
printf("测试成功!成功把rgb图转成灰度图!");
//此函数等待按键,按键盘任意键就返回
waitKey(0);
}
以上代码主要是将一个RGB原图转化为灰度图,并打印输出成功提示和两张图的窗口!
编译运行时,需要作如下配置!
如果出现以下情况,即为配置成功!
- 以上配置如此成功后,以后新建工程就不用每次都配置那么麻烦!
三,其他文章推荐
- openc4.5.2 vs2019安装教程 以及出现 LNK110:无法打开文件 “opencv_world410d.lib的解决方案
- vs2019 LNK1104: 无法打开文件opencv_world3412d.obj
- C#调用C++生成的.dll文件报错:外部组件发生异常
- opencv4以上版本报错:CV_LOAD_IMAGE_COLOR和CV_BGR2HSV和CV_CAP_PROP_FRAME_WIDTH
- Visual Studio 2019 如何新建 Win32项目
- 【OpenCV入门教程之一】 安装OpenCV:OpenCV 3.0、OpenCV 2.4.8、OpenCV 2.4.9 +VS 开发环境配置这份博文和博主非常推荐,里面OpenCV非常详细,可惜该博主斯人已去(鹅厂系的大佬)!
- win10下VS2019配置opencv-4.5.2环境配置教程
未定义标识符“CV_BGR2GRAY“
- 最后想说的,vs真是大坑,建议用opencv和vs不那么新,因为越新的话其实vs配置得越麻烦,也建议小伙伴不要更新到win11,坑更大,最后安装成功,你得会吐槽一番MS的!
- 文中若有不足,敬请批评指正!
边栏推荐
- [summary of knowledge points] chi square distribution, t distribution, F distribution
- idea 好用插件汇总!!!
- Golang panic recover custom exception handling
- kubeadm搭建kubenetes 集群(个人学习版)
- Make Tiantou village sweet. Is Xianjing taro or cabbage the characteristic agricultural product of Tiantou Village
- SOE spatial analysis server MySQL and PostGIS geospatial database of Postgres anti injection attack
- How does the port scanning tool help enterprises?
- 【ManageEngine卓豪】网络运维管理是什么,网络运维平台有什么用
- Self confidence is indispensable for technology
- Save data in browser to local file
猜你喜欢

lxml模块(数据提取)
![[file system] how to run squashfs on UBI](/img/d7/a4769420c510c47f3c2a615b514a8e.png)
[file system] how to run squashfs on UBI

【KV260】利用XADC生成芯片温度曲线图

One of the characteristic agricultural products that make Tiantou village, Guankou Town, Xiamen into a "sweet" village is

浅谈SIEM
![[automatic operation and maintenance] what is the use of the automatic operation and maintenance platform](/img/14/756d566744d6e4a988a284c5b30130.png)
[automatic operation and maintenance] what is the use of the automatic operation and maintenance platform

C语言课设物业费管理系统(大作业)

C语言课设职工信息管理系统(大作业)

SystemVerilog learning-10-validation quantification and coverage

MongoDB:一、MongoDB是什么?MongoDB的优缺点
随机推荐
[file system] how to run squashfs on UBI
【ITSM】什么是ITSM,IT部门为什么需要ITSM
C语言课设学生考勤系统(大作业)
【Unity Shader 消融效果_案例分享】
Pychart configuring jupyter
【自动化运维】自动化运维平台有什么用
Solve the problem of garbled files uploaded by Kirin v10
SQL语句
The row and column numbers of each pixel of multi-source grid data in the same area are the same, that is, the number of rows and columns are the same, and the pixel size is the same
请求模块(requests)
【ManageEngine卓豪 】助力世界顶尖音乐学院--茱莉亚学院,提升终端安全
Diffusion (multi-source search)
Dongle data collection
To sort out the anomaly detection methods, just read this article!
sql中TCL语句(事务控制语句)
证券类开户有什么影响 开户安全吗
记磁盘扇区损坏导致的Mysql故障排查
FPGA - 7 Series FPGA internal structure clocking-01-clock Architecture Overview
MongoDB:一、MongoDB是什么?MongoDB的优缺点
SystemVerilog learning-07-class inheritance and package use

