Ask Your Question
2

simple image display code not working in qt creator

asked 2013-03-16 09:00:19 -0600

Capton gravatar image

Hello everyone, I'm running a a simple image display program with opencv in QtCreator but whenever i run the code it opens a console(qtcreator_process_stub.exe),says press<return> to close window and then nothing happens Please i need help Below is my code:

MAIN.CPP

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
int main() {
Mat image= imread("imgage.jpg");
namedWindow("My Image");
imshow("My Image", image);
waitKey(5000);
return 1;
}

.PRO file:

QT += core
TARGET = opencv
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += C:/opencv/build_with_Qt/debug/include
LIBS += -LC:/opencv/build_with_Qt/debug/lib \
-lopencv_core244d\
-lopencv_highgui244d\
-lopencv_imgproc244d\
-lopencv_features2d244d\
-lopencv_calib3d244d
edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2013-04-06 12:47:33 -0600

fuego gravatar image

Did you find a solution because i have the same problem ! I have exactly the same code.

edit flag offensive delete link more
0

answered 2013-04-06 13:19:06 -0600

Basically you are using a relative path for your image. Put your image in your basic drive and use the absolute path. See if that works out for you.

Also place a debug point after the imread function and check if your Mat element actually contains data.

Also you have probably a type in the name of your image, it is now imgage, and i guess it should be image. This could also be a problem.

Also, change waitKey(5000) to waitKey(0) so that you actually have to push the button to close everything down. You can then see if there is actually something displayed in your window.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2013-03-16 09:00:19 -0600

Seen: 2,585 times

Last updated: Apr 06 '13