qt5.14.2 MSVC opencv(不结合vs)路径添加问题 测试通过

news/2024/11/17 19:29:40/文章来源:https://www.cnblogs.com/kfcalf/p/18375165

 

不换行写法

1 win32:CONFIG(release, debug|release): LIBS += -LG:/opencv4.4.0/opencv4.4_vs_msvc19_qt6.5/x64/vc17/lib/ -lopencv_aruco440 -lopencv_bgsegm440 -lopencv_bioinspired440 -lopencv_calib3d440 -lopencv_ccalib440 -lopencv_core440 -lopencv_cvv440 -lopencv_datasets440 -lopencv_dnn440 -lopencv_dnn_objdetect440 -lopencv_dnn_superres440 -lopencv_dpm440 -lopencv_face440 -lopencv_features2d440 -lopencv_flann440 -lopencv_fuzzy440 -lopencv_gapi440 -lopencv_hfs440 -lopencv_highgui440 -lopencv_imgcodecs440 -lopencv_imgproc440 -lopencv_img_hash440 -lopencv_intensity_transform440 -lopencv_line_descriptor440 -lopencv_ml440 -lopencv_objdetect440 -lopencv_optflow440 -lopencv_phase_unwrapping440 -lopencv_photo440 -lopencv_plot440 -lopencv_quality440 -lopencv_rapid440 -lopencv_reg440 -lopencv_saliency440 -lopencv_shape440 -lopencv_stereo440 -lopencv_stitching440 -lopencv_structured_light440 -lopencv_superres440 -lopencv_surface_matching440 -lopencv_text440 -lopencv_tracking440 -lopencv_video440 -lopencv_videoio440 -lopencv_videostab440 -lopencv_xfeatures2d440 -lopencv_ximgproc440 -lopencv_xobjdetect440 -lopencv_xphoto440
2 else:win32:CONFIG(debug, debug|release): LIBS += -LG:/opencv4.4.0/opencv4.4_vs_msvc19_qt6.5/x64/vc17/lib/ -lopencv_aruco440d -lopencv_bgsegm440d -lopencv_bioinspired440d -lopencv_calib3d440d -lopencv_ccalib440d -lopencv_core440d -lopencv_cvv440d -lopencv_datasets440d -lopencv_dnn440d -lopencv_dnn_objdetect440d -lopencv_dnn_superres440d -lopencv_dpm440d -lopencv_face440d -lopencv_features2d440d -lopencv_flann440d -lopencv_fuzzy440d -lopencv_gapi440d -lopencv_hfs440d -lopencv_highgui440d -lopencv_imgcodecs440d -lopencv_imgproc440d -lopencv_img_hash440d -lopencv_intensity_transform440d -lopencv_line_descriptor440d -lopencv_ml440d -lopencv_objdetect440d -lopencv_optflow440d -lopencv_phase_unwrapping440d -lopencv_photo440d -lopencv_plot440d -lopencv_quality440d -lopencv_rapid440d -lopencv_reg440d -lopencv_saliency440d -lopencv_shape440d -lopencv_stereo440d -lopencv_stitching440d -lopencv_structured_light440d -lopencv_superres440d -lopencv_surface_matching440d -lopencv_text440d -lopencv_tracking440d -lopencv_video440d -lopencv_videoio440d -lopencv_videostab440d -lopencv_xfeatures2d440d -lopencv_ximgproc440d -lopencv_xobjdetect440d -lopencv_xphoto440d
3 
4 
5 INCLUDEPATH += G:/opencv4.4.0/opencv4.4_vs_msvc19_qt6.5/include
6 DEPENDPATH += G:/opencv4.4.0/opencv4.4_vs_msvc19_qt6.5/include

 

换行写法

  1 win32:CONFIG(release, debug|release): LIBS += -LG:/opencv4.4.0/opencv4.4_vs_msvc19_qt6.5/x64/vc17/lib/ \
  2     -lopencv_aruco440 \
  3     -lopencv_bgsegm440 \
  4     -lopencv_bioinspired440 \
  5     -lopencv_calib3d440 \
  6     -lopencv_ccalib440 \
  7     -lopencv_core440 \
  8     -lopencv_cvv440 \
  9     -lopencv_datasets440 \
 10     -lopencv_dnn440 \
 11     -lopencv_dnn_objdetect440 \
 12     -lopencv_dnn_superres440 \
 13     -lopencv_dpm440 \
 14     -lopencv_face440 \
 15     -lopencv_features2d440 \
 16     -lopencv_flann440 \
 17     -lopencv_fuzzy440 \
 18     -lopencv_gapi440 \
 19     -lopencv_hfs440 \
 20     -lopencv_highgui440 \
 21     -lopencv_imgcodecs440 \
 22     -lopencv_imgproc440 \
 23     -lopencv_img_hash440 \
 24     -lopencv_intensity_transform440 \
 25     -lopencv_line_descriptor440 \
 26     -lopencv_ml440 \
 27     -lopencv_objdetect440 \
 28     -lopencv_optflow440 \
 29     -lopencv_phase_unwrapping440 \
 30     -lopencv_photo440 \
 31     -lopencv_plot440 \
 32     -lopencv_quality440 \
 33     -lopencv_rapid440 \
 34     -lopencv_reg440 \
 35     -lopencv_saliency440 \
 36     -lopencv_shape440 \
 37     -lopencv_stereo440 \
 38     -lopencv_stitching440 \
 39     -lopencv_structured_light440 \
 40     -lopencv_superres440 \
 41     -lopencv_surface_matching440 \
 42     -lopencv_text440 \
 43     -lopencv_tracking440 \
 44     -lopencv_video440 \
 45     -lopencv_videoio440 \
 46     -lopencv_videostab440 \
 47     -lopencv_xfeatures2d440 \
 48     -lopencv_ximgproc440 \
 49     -lopencv_xobjdetect440 \
 50     -lopencv_xphoto440
 51 
 52 else:win32:CONFIG(debug, debug|release): LIBS += -LG:/opencv4.4.0/opencv4.4_vs_msvc19_qt6.5/x64/vc17/lib/ \
 53     -lopencv_aruco440d \
 54     -lopencv_bgsegm440d \
 55     -lopencv_bioinspired440d \
 56     -lopencv_calib3d440d \
 57     -lopencv_ccalib440d \
 58     -lopencv_core440d \
 59     -lopencv_cvv440d \
 60     -lopencv_datasets440d \
 61     -lopencv_dnn440d \
 62     -lopencv_dnn_objdetect440d \
 63     -lopencv_dnn_superres440d \
 64     -lopencv_dpm440d \
 65     -lopencv_face440d \
 66     -lopencv_features2d440d \
 67     -lopencv_flann440d \
 68     -lopencv_fuzzy440d \
 69     -lopencv_gapi440d \
 70     -lopencv_hfs440d \
 71     -lopencv_highgui440d \
 72     -lopencv_imgcodecs440d \
 73     -lopencv_imgproc440d \
 74     -lopencv_img_hash440d \
 75     -lopencv_intensity_transform440d \
 76     -lopencv_line_descriptor440d \
 77     -lopencv_ml440d \
 78     -lopencv_objdetect440d \
 79     -lopencv_optflow440d \
 80     -lopencv_phase_unwrapping440d \
 81     -lopencv_photo440d \
 82     -lopencv_plot440d \
 83     -lopencv_quality440d \
 84     -lopencv_rapid440d \
 85     -lopencv_reg440d \
 86     -lopencv_saliency440d \
 87     -lopencv_shape440d \
 88     -lopencv_stereo440d \
 89     -lopencv_stitching440d \
 90     -lopencv_structured_light440d \
 91     -lopencv_superres440d \
 92     -lopencv_surface_matching440d \
 93     -lopencv_text440d \
 94     -lopencv_tracking440d \
 95     -lopencv_video440d \
 96     -lopencv_videoio440d \
 97     -lopencv_videostab440d \
 98     -lopencv_xfeatures2d440d \
 99     -lopencv_ximgproc440d \
100     -lopencv_xobjdetect440d \
101     -lopencv_xphoto440d

 

最简单测试代码,不加按钮,启动后直接读取硬盘上一张图片

 1 #include "mainwindow.h"
 2 #include "ui_mainwindow.h"
 3 
 4 #include <opencv2/core/core.hpp>
 5 #include <opencv2/highgui/highgui.hpp>
 6 #include <opencv2/imgproc/imgproc.hpp>
 7 
 8 using namespace cv;
 9 
10 MainWindow::MainWindow(QWidget *parent)
11     : QMainWindow(parent)
12     , ui(new Ui::MainWindow)
13 {
14     ui->setupUi(this);
15 
16     cv::Mat image = imread("D:\\2.jpg");
17     namedWindow("Display window",WINDOW_AUTOSIZE);
18     imshow("Display window",image);
19     waitKey(0);
20 }
21 
22 MainWindow::~MainWindow()
23 {
24     delete ui;
25 }

 

添加按钮后代码,可点击按钮打开图片

 1 #include "mainwindow.h"
 2 #include "ui_mainwindow.h"
 3 
 4 #include <QFileDialog>
 5 #include <QMessageBox>
 6 #include <QPixmap>
 7 
 8 #include <opencv2/opencv.hpp>
 9 #include <opencv2/imgproc.hpp>
10 
11 using namespace cv;  // 引入opencv的命名空间
12 using namespace std;
13 
14 MainWindow::MainWindow(QWidget *parent)
15     : QMainWindow(parent)
16     , ui(new Ui::MainWindow)
17 {
18     ui->setupUi(this);
19 }
20 
21 MainWindow::~MainWindow()
22 {
23     delete ui;
24 }
25 
26 void MainWindow::on_pushButton_clicked()
27 {
28     QString filename = QFileDialog::getOpenFileName(this, "打开图像文件", "C:/Users", "Image Files (*.bmp;*.png;*.jpg)");
29 
30     if (filename.isEmpty()) {
31         QMessageBox::information(this, "提示", "文件打开失败1!");
32         return;
33     }
34     Mat img_input;
35     img_input = imread(filename.toLocal8Bit().toStdString());
36 
37     if (img_input.empty()) {
38 
39         QMessageBox::information(this, "提示", "文件打开失败2!");
40         return;
41     }
42     cv::Mat temp;
43     cv::cvtColor(img_input, temp, cv::COLOR_BGR2RGB);
44 
45     namedWindow("Display window",WINDOW_AUTOSIZE);
46     imshow("Display window",img_input);
47     waitKey(0);
48 
49     MainWindow w;
50     w.show();
51 }

 相对来说qt+mingw+opencv的路径就比较简单

1 #包含路径
2 INCLUDEPATH += E:\opencv\opencv4.5.4_mingw730_64_qt5.14.2\include
3 
4 #库文件
5 LIBS += E:\opencv\opencv4.5.4_mingw730_64_qt5.14.2\x64\mingw\lib\libopencv*.a

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/785924.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Java学习笔记7-变量

1.1变量是程序的基本组成单位 不论是使用那种高级别语言,变量都是其程序的基本组成单位,比如1.2概念 变量相当于内存中一个数据存储空间 的表示,你可以把变量看做是一个房间的门牌号,通过 门牌号 我们可以找到房 间,而通过变量名可以访问到变量 ( 值 ) 。 1.3变量的使用步…

什么?!90%的ThreadLocal都在滥用或错用!

最近发现系统里面在使用到了 ThreadLocal,乍一看,好像很高级的样子。再仔细一看,完全就是一个 ThreadLocal 滥用的典型案例啊!甚至,日常的业务系统中,90%以上都在滥用或者错用啊最近在看一个系统代码时,发现系统里面在使用到了 ThreadLocal,乍一看,好像很高级的样子。…

半导体行业的数据革命:高性能数据采集系统如何改变游戏规则!

随着国产替代和半导体工厂扩产潮,半导体工厂有着大量建厂和设备管理需求,设备数据采集作为现代工业生产与管理的关键环节,其重要性不言而喻,数字化转型正深刻推动半导体制造企业实现远程监控、提高生产效率、降低生产成本、优化产品质量及明晰精细化方向。 半导体机台设备…

除了按值和引用,方法参数的第三种传递方式

参数在方法种具有按“值(by value)”和“引用(by ref)”两种传递方式,这是每个.NET程序员深入骨髓得基本概念。但是我若告诉你,.NET规定的参数传递形式其实是三种,会不会颠覆你的认知。参数在方法种具有按“值(by value)”和“引用(by ref)”两种传递方式,这是每个…

强!34.1K star! 再见Postman,新一代API测试利器,功能强大、颜值爆表!

1、引言 在当今的互联网时代,API(应用程序编程接口)已经成为连接不同软件系统的桥梁。作为一名开发者,掌握API测试技能至关重要。市面上的API测试工具琳琅满目,今天我们要介绍的是一款开源、跨平台的API测试工具——Insomnia。 2、Insomnia介绍 Insomnia是一款功能丰富、易…

Modbus初学者教程,第五章:Modbus 中的功能码和异常码

第五章:Modbus 中的功能码和异常码平时调试Modbus设备,或者学习Modbus协议,推荐一款Modbus主从站模拟器: 主站下载地址:Modbus从站模拟器 从站下载地址:Modbus主站模拟器可视化 Modbus 设备中的数据 Modbus 从设备可以想象为具有一个内部电子表格,其中填满了数字。Modbu…

袋鼠

先转化一下题意:求有多少个1~n的排列p能够满足 \(\forall i \in (1,n)\) ,使 $ p_{i} $ 左右两边的数同时小于或者大于 \(p_{i}\) ,并且\(p_{1}=s,p_{n}=t\) 。 比较明显的预设型DP(连转化题意我都做不到,悲),先正常来分析一下,我们填数从小往大枚举,如果我们填入一个数,…

JetBrains Writerside 2024.2 (macOS, Linux, Windows) - 编写、测试、构建和发布最佳教程

JetBrains Writerside 2024.2 (macOS, Linux, Windows) - 编写、测试、构建和发布最佳教程JetBrains Writerside 2024.2 (macOS, Linux, Windows) - 编写、测试、构建和发布最佳教程 JetBrains 跨平台开发者工具 请访问原文链接:https://sysin.org/blog/jetbrains-writerside/…

Citrix ADC Release 13.1 Build 54.29 (nCore, VPX, SDX, CPX, BLX) - 混合多云应用交付控制器

Citrix ADC Release 13.1 Build 54.29 (nCore, VPX, SDX, CPX, BLX) - 混合多云应用交付控制器Citrix ADC Release 13.1 Build 54.29 (nCore, VPX, SDX, CPX, BLX) - 混合多云应用交付控制器 Citrix ADC - 混合多云应用交付控制器 请访问原文链接:https://sysin.org/blog/citr…

Metasploit Pro 4.22.3-2024081901 (Linux, Windows) - 专业渗透测试框架

Metasploit Pro 4.22.3-2024081901 (Linux, Windows) - 专业渗透测试框架Metasploit Pro 4.22.3-2024081901 (Linux, Windows) - 专业渗透测试框架 Rapid7 Penetration testing, release Aug 19, 2024 请访问原文链接:https://sysin.org/blog/metasploit-pro-4/,查看最新版。…

dotnet X11 栈空间被回收导致调用 XPutShmImage 闪退

本文记录在使用 X11 过程中的问题,由于不正确使用导致栈空间被回收,从而在调用 XPutShmImage 时让应用闪退,此问题本质上讲只和 X11 的设计有一分钱关系,更多的问题在于我的写法上在 上一篇博客 里,介绍了使用 MIT-SHM 共享内存推送图片,详细请看:dotnet X11 简单使用 M…

Avalonia 11.1 已知问题 IterationCount 为 Infinite 的动画播放出现异常

如果在 Avalonia 后台代码播放一个动画,这个动画的 Animation 的 IterationCount 被设置为 Infinite 那么将在播放的时候抛出 InvalidOperationException 异常本文所使用的 Avalonia 为 11.1.0 版本,由于 Avalonia 行为和 API 变动较多,如大家使用其他版本还请重新测试 如以…