1

Recently build OPENCV 3.4.3 with CMAKE 3.12.4 and MINGW64(32bit) 8.1.0 in Windows 7. Have QT 5.6 and i trying to test this build as QT Console App, but when i compiling with QT only get the message "Press "RETURN" to close this window...".

.PRO file:

CONFIG += c++11
TARGET = test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
OTHER_FILES += test.png
INCLUDEPATH += C:\Users\Test\Desktop\opencv\build\include
LIBS += C:\Users\Test\Desktop\mingw\bin\libopencv_*.dll

main.cpp:

#include <QCoreApplication>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"

using namespace std;

int main(int argc, char *argv[]) {
    QCoreApplication a(argc, argv);
    cout << "Hello World!" << endl;
    cv::Mat mat;
    mat = cv::imread("test.png");
    cvNamedWindow("hello");
    cv::imshow("hello",mat);
    return a.exec();
}

What im doing wrong?

Siewdass Sf
  • 169
  • 1
  • 10

1 Answers1

2

Imo the problem is not in your code, I just run it (using Qt5.5, Win10, openCV 4 and mingw64), even if I had to change cvNamedWindow to cv::namedWindow. I have two hints:

  • did you build openCV with mingw64? If not, do so.
  • are the openCV dlls in the path when you run the application? You can also copy all opencv dlls in the program folder to check that quickly...
L.C.
  • 1,098
  • 10
  • 21
  • Omg i forgot that x.x now, it works i get this error. "error assertion failed (size.width 0 && size.height 0)" but i resolve it with this: https://stackoverflow.com/questions/31341845/opencv-error-assertion-failed-size-width0-size-height0-simple-code thanks!!!! – Siewdass Sf Nov 12 '18 at 14:12