Qt configuration OpenCV tutorial, no complicated compilation process, (detailed version)

Win10 system Qt5.9.2 configuration OpenCV 4.5.0 library tutorial (the OpenCV library has been compiled and can be used directly)

Qt and opencv installation package resources

Cloud disk link: https://pan.baidu.com/s/1stA2sQzfpiuyG8rtooJJ4A 
Extraction code: 809t

        

Not much to say, the configuration process is as follows: Double-click the Qt installation package

1. Qt installation

click next

Click Skip

 

Set the installation path (I installed both qtCreator and opencv to the Qt folder), and then click Next

 

In Qt5.9.2, click to expand, and check MinGw 5.3.0 32bit; check the Tools component as shown below;

 After the selection is complete, go to the next step until you click Install

 

 At this point, the QtCreator installation has ended, and the files are shown in the figure below

 Second, the installation of opencv

This is relatively simple, because the compiled opencv is used, and the OpenCV file in the cloud disk is directly copied and put into Qt.

The first folder is directly copied from the cloud disk, and the second is the path of Qt just now. For convenience, I put them all under the same folder.

 3. Environment variable settings of Qt and opencv

 Qt and OpenCV each need to configure a Path path,

Qt的Path:H:\Qt\qt5.9.2\Tools\mingw530_32\bin

 OpenCV的Path:H:\Qt\opencv3.4.0\OpenCV-MinGW-Build-OpenCV-3.4.5\x86\mingw\bin

 

  4. Verify the effect

Create a new project to read and display a picture from the disk, but you need to configure it in the .pro file before clicking Run :

 

The configuration of the .Pro file needs to add INCLUDEPATH and LIBS;

Note that the path has backslashes, not slashes.

INCLUDEPATH +=H:\Qt\opencv3.4.0\OpenCV-MinGW-Build-OpenCV-3.4.5\include \
              H:\Qt\opencv3.4.0\OpenCV-MinGW-Build-OpenCV-3.4.5\include \
              H:\Qt\opencv3.4.0\OpenCV-MinGW-Build-OpenCV-3.4.5\include\opencv2

LIBS +=H:\Qt\opencv3.4.0\OpenCV-MinGW-Build-OpenCV-3.4.5\x86\mingw\bin\libopencv_*.dll

 After the path is added, here is an example of reading a picture from the disk, click Run to see the effect.

 The result looks like this:

 

Suggestion: I don't really understand the configuration of Qt and opencv, but this configuration method is simple, fast and can be used directly. Pay attention to the path when configuring, don’t make a mistake, it’s basically OK.

Guess you like

Origin blog.csdn.net/qq_42027706/article/details/122210273