QT--Configure Opencv

Tip: This article is a learning record. If you have any questions, please contact the author in time.


foreword

Only be the first me, not the second who.

1. Download the compiled opencv

Works with the mingw compiler.
Baidu network disk link
Link: https://pan.baidu.com/s/1RyYwkItpL-ea7K81qsdqZw
Extraction code: q46x

1... Unzip

Unzip it and put it in the same directory as QT, which is convenient for subsequent search

insert image description here

2... path path

After adding the path
insert image description here
and editing successfully, remember to restart the computer, otherwise there will be exceptions in the subsequent running of the program.
as shown in the picture
insert image description here

2. Use steps

1...pro file

Add opencv dynamic library

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

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

2...h file

add header file

#include "opencv2/opencv.hpp"

In the header file you can add:

using namespace cv;

Or add scope when using library functions

cv::XXX

Only in this way can the library functions in opencv be used
. Tip: Mat in opencv is QImage in QT, and how to convert the two will be introduced later.

Summarize

Good at summarizing, go further.

Guess you like

Origin blog.csdn.net/m0_51988927/article/details/131175500