0

I am working on the following code:

main.cpp

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

using namespace cv;

using namespace std;

int main(int argc, char *argv[])
{
    Mat image = imread("C:/Users/Public/Pictures/Sample Pictures/Tulips.jpg");
    namedWindow("Image");
    imshow("Image",image);
    waitKey(0);
}

Test.pro

#-------------------------------------------------
#
# Project created by QtCreator 2013-05-07T10:38:38
#
#-------------------------------------------------

QT       += core

QT       -= gui

TARGET = Test
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app


SOURCES += main.cpp
INCLUDEPATH += E:/Jasmin/Yohan/opencv/build/include
INCLUDEPATH += E:/Jasmin/Yohan/opencv/include/opencv2

LIBS += E:/Jasmin/Yohan/opencv/build/x86/mingw/lib/libopencv_calib3d240.dll.a
LIBS += E:/Jasmin/Yohan/opencv/build/x86/mingw/lib/libopencv_contrib240.dll.a
LIBS += E:/Jasmin/Yohan/opencv/build/x86/mingw/lib/libopencv_core240.dll.a
LIBS += E:/Jasmin/Yohan/opencv/build/x86/mingw/lib/libopencv_highgui240.dll.a
LIBS += E:/Jasmin/Yohan/opencv/build/x86/mingw/lib/libopencv_imgproc240.dll.a

When I run this code, no image is showing up, the following output get printed

Starting E:\Jasmin\Yohan\QTProjects\build-Test-Desktop_Qt_5_0_2_MinGW_32bit-Debug\debug\Test...
E:\Jasmin\Yohan\QTProjects\build-Test-Desktop_Qt_5_0_2_MinGW_32bit-Debug\debug\Test exited with code 0

Following opencv related environment variables are added to the "path" system variable

E:\Jasmin\Yohan\opencv\build\x86\mingw\bin;E:\Jasmin\Yohan\opencv\build\x86\vc10\bin

Why I am getting this issue? My QT creator version is 2.7.0

Update

This is what my debugger has to say:

enter image description here

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
PeakGen
  • 21,894
  • 86
  • 261
  • 463

2 Answers2

0

Your code seems to be doing what it should: waitKey(0) waits zero seconds or milliseconds and program quits. Increase waiting time or put waitKey in loop..

noSkill
  • 68
  • 5
0

Using the libs in "...\opencv\build\x86\mingw\bin" and "...\opencv\build\x86\mingw\lib

You can not use the libraries that come with OpenCV-2.4.x.exe.

As some developers in forums and I find out. On some systems, the precompiled libs of "opencv 2.4.x" can not be used. To compile your own programs, works, but it crashed if you try to run them. Until there are not functioning precompiled libs of "opencv 2.4.x , you have to compile opencv yourself.

Ignore so the folder "...\opencv\build\x86\mingw\bin" and "...\opencv\build\x86\mingw\lib" completely.

Using the libs

How to build and use openCV

Community
  • 1
  • 1
moskito-x
  • 11,832
  • 5
  • 47
  • 60