The result is not an error, but what all don't, according to the printf doesn't show... Strange, the compiler cmake. Remove namewindow and imshow printf is normal.
This is the main file
# include & lt; QCoreApplication>
# include "opencv2/opencv. HPP"
using namespace cv;
Int main (int arg c, char * argv [])
{
QCoreApplication a (arg c, argv);
Mat image=imread (" C:/Users/Administrator/Desktop/1. JPG ");
If (image. The empty ())
{
Fprintf (stderr, "Error: load the image failed.");
The return - 1;
}
NamedWindow (" test ", CV_WINDOW_AUTOSIZE);
Imshow (" test ", image);
Printf (" * * * * ");
Return a.e xec ();
}
This is a pro file
QT GUI -=
CONFIG + 11=c + + console
The CONFIG -=app_bundle
# The following define top service your compiler emit warnings if you use The
# any feature of Qt which as had been marked deprecated (the exact warnings
# depend on your compiler). Both Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES +=QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile the if You use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select the to disable deprecated APIs only up to a certain version of Qt.
# # DEFINES +=QT_DISABLE_DEPRECATED_BEFORE=0 x060000 disables all the APIs deprecated before Qt 6.0.0
INCLUDEPATH +=E:/opencv - 3.2.0/newbuild/install/include \
E:/opencv - 3.2.0/newbuild/install/include/opencv \
E:/opencv - 3.2.0/newbuild/install/include/opencv2
LIBS +=E:/opencv - 3.2.0/newbuild/install/x86/mingw/lib/libopencv_core320. DLL. A \
E:/opencv - 3.2.0/newbuild/install/x86/mingw/lib/libopencv_highgui320. DLL. A \
E:/opencv - 3.2.0/newbuild/install/x86/mingw/lib/libopencv_imgproc320. DLL. A \
E:/opencv - 3.2.0/newbuild/install/x86/mingw/lib/libopencv_imgcodecs320. DLL. A \
E:/opencv - 3.2.0/newbuild/install/x86/mingw/lib/libopencv_highgui320. DLL. A \
E:/opencv - 3.2.0/newbuild/install/x86/mingw/lib/libopencv_videoio320. DLL. A
+=the main SOURCES. The CPP
I refer to is the following this blog https://blog.csdn.net/Betterc5/article/details/88374258
Is a platform.
CodePudding user response:
Qt console output with the qDebug () & lt;CodePudding user response:
Just call opencv imshow (" test ", the image). Will not display images, need to add one line of code:Imshow (" test ", image);
WaitKey (1);
CodePudding user response:
You this and Qt do not have what relation, you using opencv is wrong, you can use the example of opencv officialCodePudding user response: