Just started to contact opencv and qt, when I use qt 6, according to the routines in the book entered the corresponding code, but in the compilation stage has been reported an error, originally thought that the opencv library is not compiled well, but using vs2022 there is no problem, the following is some code snippets
// vscode
using namespace cv;
Mat image = imread("C:\Users\Documents\Screenshot 2023-07-30 205234.png");
imshow("Output", image);
follow is qt creater
#.pri
INCLUDEPATH += D:/data/opencv-4.10.0/opencv-4.10.0/_build/install/include
Debug:{
LIBS += D:/data/opencv-4.10.0/opencv-4.10.0/_build/install/x64/vc17/lib/opencv_world4100d.lib
}
Release:{
LIBS += D:/data/opencv-4.10.0/opencv-4.10.0/_build/install/x64/vc17/lib/opencv_world4100.lib
}
// qform
#include "mainwindow.h"
#include <QApplication>
#include "opencv2/opencv.hpp"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
cv::Mat image = cv::imread("C:/Users/邵长虹/Documents/Screenshot 2023-07-30 205234.png");
cv::imshow("Output", image);
MainWindow w;
w.show();
return a.exec();
}
error info
enter image description here
This is the sample code on my reference sheet
enter image description here
The compiler I use is MinGW so what can I do to fix this
望曉天 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.