码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • OpenCV1-VS2022+OpenCV环境配置


    OpenCV学习1-VS2022+OpenCV环境配置

      • 1.VS、Image Watch、FastStone Image Viewer、OpenCV
      • 2.VS2022配置OpenCV环境
      • 3.Debug模式下日志的关闭


    1.VS、Image Watch、FastStone Image Viewer、OpenCV

    1.安装VS2022

    2.安装看图拓展:Image Watch for Visual Studio 2022

    3.安装图像对比软件 FastStone Image Viewer

    4.OpenCV官网下载:opencv.org/release

    2.VS2022配置OpenCV环境

    配置:

    1.添加环境变量D:\ThirdLib\opencv\build\x64\vc16\bin

    2.添加包含目录:

    D:\ThirdLib\opencv\build\include\opencv2

    D:\ThirdLib\opencv\build\include\

    3.添加库目录:

    D:\ThirdLib\opencv\build\x64\vc16\lib

    4.添加附加依赖项:库目录下的文件

    如果是Release版本:opencv_world480.lib

    如果是Debug版本:opencv_world480d.lib

    get-started 测试程序:

    #include 
    #include 
    
    using namespace cv;
    
    int main()
    {
    	std::string image_path = "path/to/image";
    	Mat img = imread(image_path, IMREAD_COLOR);
    
    	imshow("Display window", img);
    	int k = waitKey(0); // Wait for a keystroke in the window
    	return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    3.Debug模式下日志的关闭

    如果实在Debug模式下,则会输出大量日志信息,使用以下代码可以关闭日志的输出:

    // 包含头文件
    #include 
    
    // main函数中
    cv::utils::logging::setLogLevel(utils::logging::LOG_LEVEL_SILENT);
    
    • 1
    • 2
    • 3
    • 4
    • 5
    #include 
    #include 
    #include 
    
    using namespace cv;
    using namespace std;
    
    int main()
    {
    	cout << "OpenCV Version: " << CV_VERSION << endl;
    	utils::logging::setLogLevel(utils::logging::LOG_LEVEL_SILENT);
    
    	// jpg图片
    	string image_path = "morty.jpg";
    	Mat img_jpg = imread(image_path, IMREAD_UNCHANGED);
    	if (img_jpg.empty())
    	{
    		cout << "Input image is null!" << endl;
    		return 0;
    	}
    	imshow(image_path, img_jpg);
    	cout << "Channel nmuber: " << img_jpg.channels() << endl;
    	cout << "Size: " << img_jpg.size << endl;
    
    	// png图片
    	image_path = "skinner.png";
    	Mat img_png = imread(image_path, IMREAD_UNCHANGED);
    	if (img_png.empty())
    	{
    		cout << "Input image is null!" << endl;
    		return 0;
    	}
    	imshow(image_path, img_png);
    	cout << "Channel nmuber: " << img_png.channels() << endl;
    	cout << "Size: " << img_png.size() << endl;
    
    	int k = waitKey(0); // Wait for a keystroke in the window
    	return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
  • 相关阅读:
    如何使用 Lambda 导出 EXCEL,并且实现本地调试
    Cplex求解教程(基于OPL语言,可作为大规模运算输入参考)
    猿创征文|网络安全的十大经典工具介绍
    【微服务】API治理发展历史与未来趋势
    python输出HelloWorld
    Java知识点
    git工具 —— git clean 解析
    Day 56 | 583. 两个字符串的删除操作 & 72. 编辑距离 & 编辑距离总结篇
    MacOS Anaconda 安装教程及虚拟环境创建
    SpringBoot 监控
  • 原文地址:https://blog.csdn.net/ArthurHai521/article/details/133640994
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号