首页 > 其他分享 >qt5.14.2 MSVC opencv(不结合vs)路径添加问题 测试通过

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

时间:2024-08-23 09:06:32浏览次数:11  
标签:qt5.14 lopencv img opencv opencv4.4 测试通过 ui include MainWindow

 

不换行写法

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

 

标签:qt5.14,lopencv,img,opencv,opencv4.4,测试通过,ui,include,MainWindow
From: https://www.cnblogs.com/kfcalf/p/18375165

相关文章

  • Qt5.14.2 MinGW7.3.0_64 opencv helloworld
    路径配置.proINCLUDEPATH+=E:\Opencv\includeLIBS+=E:\Opencv\x64\mingw\lib\libopencv_*.a 点击按钮打开一张图片1#include"mainwindow.h"2#include"ui_mainwindow.h"3#include<QFileDialog>4#include<QMessageBox>5......
  • OpenCV 机器人手眼标定
    OpenCV机器人手眼标定(九点标定法)对于初学者而言,对相机的标定经常模糊不清。不知道机器坐标与相机坐标如何转换,两个坐标系又是如何建立?我们通常是利用张氏标定法,针对于相机的畸变进行标定,利用校正得到的参数对图形进行处理后再呈现出来。这个方法网上用的人很多,资......
  • java opencv 获取图中物品的倾斜角度(单个物品,如果存在多个物品,建议先将多个物品处理成
    //1、先连上opencv包System.setProperty("java.awt.headless","false");System.out.println(System.getProperty("java.library.path"));URLurl=ClassLoader.getSystemResource("lib/opencv/opencv_java4100.dll");System.load(url.g......
  • 【OpenCV教程】特征工程
    @目录1.模板匹配1.1原理1.2API1.3模板匹配计算方法1.4掩码的使用获得掩码1.5效果1.5模板匹配的缺陷无法应对旋转无法应对缩放2.cornerHarris(对灰度图)2.1角点的描述2.2原理(前置知识要求:线性代数)(以下为bolcksize=2的情况)2.3API2.4流程2.5优点与缺点测试代码图片旋转,角......
  • 【OpenCV教程】轮廓检测过程
    @目录1.查找轮廓1.1API1.2轮廓层级检测模式:索引号(层级)RETR_EXTERNAL(索引顺序:从右下到左上)RETR_LIST(recommended)(索引顺序:从右下到左上,由外到内)RETR_CCOMP(notrecommended)(索引顺序:由内到外,从右下到左上)RETR_TREE(recommended)1.3轮廓坐标点储存方式2.绘制轮廓2.1API3.轮廓面......
  • OpenCV(cv::SparseMat)
    目录1.主要特点和用途2.主要方法和成员函数3.示例代码4.优缺点cv::SparseMat是OpenCV中表示稀疏矩阵的类。稀疏矩阵用于存储大多数元素为零的矩阵,以节省内存和计算时间。与普通的密集矩阵不同,稀疏矩阵仅存储非零元素及其坐标。1.主要特点和用途稀疏数据存储:当......
  • ArchLinux配置OpenCV C++环境
    本文将简单介绍在ArchLinux中安装OpenCVC++库并运行一个简单的OpenCV程序的过程。参考:https://github.com/donaldssh/Install-OpenCV我的环境最新的ArchLinuxKDEPlasma6桌面环境OpenCV4.10.0clang18.1.8gcc14.2.1安装安装以下包:sudopacman-Shdf5vtk......
  • python opencv实时视频输入
    要在Python中使用OpenCV进行实时视频输入,可以按照以下步骤进行操作:首先,需要安装OpenCV库。可以使用pipinstallopencv-python命令来安装OpenCV。导入所需的库:importcv2创建一个VideoCapture对象来读取视频输入:cap=cv2.VideoCapture(0)这里的参数0表示使用计......
  • OpenCV-Python系列之对极几何
    点击查看代码importnumpyasnpimportcv2ascvimg1=cv.imread("data1/1.png",0)#queryimageleftimageimg2=cv.imread("data1/2.png",0)#trainimagerightimagesift=cv.SIFT_create()#sift1=cv.xfeatures2d.SIFT_create()kp1,des1=sift.dete......
  • 【OpenCV_python】凸包检测 轮廓特征 直方图均衡化 模板匹配 霍夫变换
    凸包特征检测凸包就是图像的最小外接多边形,通过图像的轮廓点,找到距离最远的两个点的直线,根据直线找到距离最远的下一个点,直到所有的点被包围在多边形内读取图像二值化找图像的轮廓获取凸包点的坐标绘制凸包点convexHull获得图像的凸包点cv2.convexHull(points,hu......