Reputation: 685
I have installed Qt5.13 and linked opencv version 4.0 . But application is crashing when I am trying to use opencv library; otherwise it will work
.pro file
INCLUDEPATH += C:\opencv\build\include
LIBS += -L"C:\\opencv\\build\\x64\\vc15\\lib" \
-lopencv_world410
Mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "opencv2/opencv.hpp"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
cv::Mat img = cv::imread("qq.jpg");
cv::imshow("ee",img);
cv::waitKey(0);
}
MainWindow::~MainWindow()
{
delete ui;
}
Every solution is appreciated.
Upvotes: 0
Views: 183
Reputation: 1247
This is how I included my OpenCV DLL in my .pro file. Yes, DLL, I prefer just using the functions I need instead of including the whole OpenCV Library in my project.
LIBS += -L$$PWD/Libs/OpenCV \
-lopencv_core320 \
-lopencv_imgproc320 \
Upvotes: 1
Reputation: 6079
The problem should be with the project configuration. You can try the following configuration and run again:
INCLUDEPATH += C:\opencv\build\include
LIBS += -LC:\opencv\build\x64\vc15\lib \
lopencv_world410.lib
So what changed?
"C:\\opencv\\build\\x64\\vc15\\lib"
C:\opencv\build\x64\vc15\lib
-lopencv_world410
lopencv_world410.lib
Hope it works!
Edit: As Scheff mentioned, add the OpenCV DLL files path to the system path variable or add thoese to the application root folder.
Upvotes: 0