Home > Mobile >  QT image processing library was established through compile Cmake OpenCV concrete steps and problem
QT image processing library was established through compile Cmake OpenCV concrete steps and problem

Time:10-21

Binocular cameras recently do space coordinates, matlab has get through soon, plan to use openCV to this process in the QT,
Because the future plans to implement in the cross-platform QT + + MinGW32 Cmake to compile,
Checked online many posts, found that do not bottom go to, an error is too much, continue to check posts, among many, finally done, now to write out the process,
Send the address of making cannot download configuration files are uploaded, also be return those selfless generosity to provide learning materials technology,
Before the QT's official website to download QT5.9, here no longer say more,


0. Compilation environment
Win10-64 - bit
Qt5.9.7
MinGW - 5.3.0-32 bit


CMake 3.18 (to CMake website to download, expanded into a directory, C: \ Users \ \ Desktop \ MyQt \ XX cmake3.18)

OpenCV 4.5 (click on the download address: https://opencv.org/in the bottom right hand corner after source forge the round button, directly out of the suitable for your computer version to download, download after run this self-extracting files, in the directory, C: \ Users \ \ Desktop \ MyQt \ XX OpenCV)


1. Inside the computer configuration system environment variable
C: \ Users \ \ Desktop \ MyQt \ XX cmake3.18 \ bin
C: \ QT \ 5.9 \ mingw53_32 \ bin;
D: \ QT \ Tools \ mingw530_32 \ bin
Here according to your own installation directory to define, can make the restart your computer,

After 2. OpenCV run self-extracting into directory, can create a build subdirectory opencvBuild,
In opencv installation directory to create a folder at the same level of opencvBuild, used to store build file and generate library, there will be compiled library's stay,
C: \ Users \ \ Desktop \ MyQt \ XX OpenCV \ opencvBuild
Then to cmake directory, open the cmake - GUI this program, set up openCV source code path and build path,

Click on the bottom of the above config, then set the compiler, the following figure



Set the compiler, click finish



(you can refer to the official documentation for https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows

3. The compiler before
Check the box [X] WITH_QT
Check the box [X] WITH_OPENGL
Set Qt5_DIR to C: \ Qt \ 5.9 \ mingw53_32 \ lib \ cmake \ Qt5 (the path according to your own revision)
Uncheck the box [] ENABLE_PRECOMPILED_HEADERS
Click the config, etc with a progress bar to complete


Then click the "add entry" button, the following the path or the value set,

The Set QT_MAKE_EXECUTABLE to C: \ Qt \ 5.9 \ mingw53_32 \ bin \ qmake exe
Set Qt5Concurrent_DIR to C: \ Qt \ 5.9 \ mingw53_32 \ lib \ cmake \ Qt5Concurrent
Set Qt5Core_DIR to C: \ Qt \ 5.9 \ mingw53_32 \ lib \ cmake \ Qt5Core
Set Qt5Gui_DIR to C: \ Qt \ 5.9 \ mingw53_32 \ lib \ cmake \ Qt5Gui
Set Qt5Test_DIR to C: \ Qt \ 5.9 \ mingw53_32 \ lib \ cmake \ Qt5Test
Set Qt5Widgets_DIR to C: \ Qt \ 5.9 \ mingw53_32 \ lib \ cmake \ Qt5Widgets
Set Qt5OpenGL_DIR to C: \ Qt \ 5.9 \ mingw53_32 \ lib \ cmake \ Qt5OpenGL
The Set CMAKE_BUILD_TYPE to Release or RelWithDebInfo
Set OPENCV_VS_VERSIONINFO_SKIP=1 (not the path are the value, in the description of the Set 1)



And then click the config, etc. The progress bar to complete, and then click Generate, progress bar after reading it, configuration is complete,

4. Step has been configured, but in the process of compiling will encounter compiler error, if you want a successful compilation, can undertake the following Settings,
Don't check the WITH_IPP
Don't check the options related to the TESTS
Don't check the ENABLE_PRECOMPILED_HEADERS
Don't check the WITH_MSMF
Check the ENABLE_CXX11
Then click config - generate, until no red part of the tip, successful compilation,

5. Here I had after the configuration above, also always error, found that because of not be able to connect to the network in the compilation, cannot download ffmpeg:
CMake Warning at CMake/OpenCVDownload. CMake: 193 (the message) :
FFMPEG: Download failed: 7;" Couldn 't connect to server "
For the details both please refer to the download the log file:

Online to find a post that shows you how to read the error message: https://www.cnblogs.com/huluwa508/p/10142718.html
How to CMakeDownloadLog. TXT inside to check the problem, but the key is to find where the three ffmpeg documentation?
And query a bunch of posts, found some only gave two files, a poor, three files must be complete, and will check MD5, make the whole day so suddenly, MD5 do not match, I asked my classmates abroad here do a favor, put this three files, here I share, as I am in the process of learning QT to countless guidance my technical posts in return, put the three files in the following directory is ok ~


Three files
Opencv_videoio_ffmpeg. DLL
Opencv_videoio_ffmpeg_64. DLL
Ffmpeg_version. Cmake

Link: https://pan.baidu.com/s/1CUih5XUOhGMnkC-iUz28gw
The extracted code: r7vP
Copy this paragraph after open the baidu network backup phone App, operation more convenient oh

Anyway, after done, the three documents config again - the generate compilation are not red,
6.
Then go to C: \ Users \ \ Desktop \ MyQt \ XX OpenCV \ opencvBuild directory
To open the CMD command window mingw32 - make



To 39% as a result, the total error

The results found a post (thank you very much)
https://blog.csdn.net/esiangchioa/article/details/107272441
Solution: will the OPENCV/CMake OPENCV_ENABLE_ALLOCATOR_STATS don't tick
The config again - the generate
To open the CMD command window in opencvBuild directory
Compile again, mingw32 - make half an hour or so
100% success!


And the last step, can not forget, in the same directory under
Mingw32 - make install to install
Library file has been created under the directory of your, you can according to the example ran a picture out testing the club's official website, I will not repeat here,








  •  Tags:  
  • Qt
  • Related