I have been following this tutorial and I did all of them carefully. But afterwards I ran the simple code:
I saw this error and how can I fix it?
Tutorial: https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows
I removed qt and opencv and I used the version that used in the tutorial that I mentioned but I got the same error.
And also I added "img.jpg" to my project directory.
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace std;
using namespace cv;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
Mat image = imread("img.jpg", 1);
namedWindow("My Image");
imshow("My Image", image);
waitKey(0);
}
MainWindow::~MainWindow()
{
delete ui;
}
and I added them to my .pro
file:
INCLUDEPATH += C:\OpenCV-Qt\build\install\include
LIBS += C:\OpenCV-Qt\build\bin\libopencv_core320.dll.a
LIBS += C:\OpenCV-Qt\build\bin\libopencv_highgui320.dll
LIBS += C:\OpenCV-Qt\build\bin\libopencv_imgcodecs320.dll
LIBS += C:\OpenCV-Qt\build\bin\libopencv_imgproc320.dll
LIBS += C:\OpenCV-Qt\build\bin\libopencv_features2d320.dll
LIBS += C:\OpenCV-Qt\build\bin\libopencv_calib3d320.dll
I expect to create a window and show the image in it but I get the error:
C:\OpenCV-Qt\build\bin\libopencv_core320.dll:-1: error: LNK1107: invalid or corrupt file: cannot read at 0x3D0