Home > Mobile >  QT& Opencv display images
QT& Opencv display images

Time:09-18

QT above build opencv environment, with a bunch of complicated QT language because see don't understand (and image becomes very small, level off 1 cm, won't change, just looking for a very simple routines, no problem, I think environment
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 official

CodePudding user response:

reference 4 floor donwmufromdying response:
you and Qt do not have what relation, you using opencv is wrong, you can use the example of opencv official

Are you sure that I VS are written, the display pictures I really is back all back out,

CodePudding user response:



Is your code, fix the WINDOW_AUTOSIZE and image file name:
 # 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 (" e:/mm. JPG ");
If (image. The empty ())
{
Fprintf (stderr, "Error: load the image failed.");
The return - 1;
}
NamedWindow (" test ", WINDOW_AUTOSIZE);
Imshow (" test ", image);
Printf (" * * * * ");
Return a.e xec ();
}

Pro is similar:
 QT GUI -=

CONFIG + 11=c + + console
The CONFIG -=app_bundle

DEFINES +=QT_DEPRECATED_WARNINGS

SOURCES +=\
The main. CPP


INCLUDEPATH +=C:/opencv/build/include
The CONFIG (debug, the debug | release) {
LIBS +=- LC:/opencv/build/x64/vc15/lib - lopencv_world420d
} else {
LIBS +=- LC:/opencv/build/x64/vc15/lib - lopencv_world420
}

DESTDIR=$${PWD}/bin/amd64

QNX: target path=/TMP/$${target}/bin
The else: Unix:! Android: target path=/opt/$${target}/bin
! IsEmpty (target path) : INSTALLS +=target

CodePudding user response:

The
reference 6 floor Hua. R response:


Is your code, fix the WINDOW_AUTOSIZE and image file name:
 # 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 (" e:/mm. JPG ");
If (image. The empty ())
{
Fprintf (stderr, "Error: load the image failed.");
The return - 1;
}
NamedWindow (" test ", WINDOW_AUTOSIZE);
Imshow (" test ", image);
Printf (" * * * * ");
Return a.e xec ();
}

Pro is similar:
 QT GUI -=

CONFIG + 11=c + + console
The CONFIG -=app_bundle

DEFINES +=QT_DEPRECATED_WARNINGS

SOURCES +=\
The main. CPP


INCLUDEPATH +=C:/opencv/build/include
nullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • Qt
  • Related