Install OpenCV4.1.0 with CMake-gui in Ubuntu18.04

Install OpenCV4.1.0 with CMake-gui in Ubuntu18.04

1.install cmake-gui

sudo apt-get install cmake-qt-gui

2. Configure OpenCV

1. Decompress (extract) OpenCV4.1.0 and OpenCV_contrib-4.1.0, as shown in the figure

insert image description here
2. Double-click to enter the unzipped OpenCV4.1.0 folder, right-click to open the terminal (or open the terminal elsewhere, enter the current directory by entering cd opencv4.1.0), and then enter in sequence (don’t forget the last space in the third line and two dots):

mkdir build
cd build 
cmake-gui .. 

3. Then the graphical interface of CMake will pop up. In the two paths above, select the path of the folder where the code is located and the path to be installed. 4. Click the Configure
insert image description here
button at the bottom left, select Unix Makefiles, and select Use default native compilers (default), and then click Finish
insert image description here
5. Some files need to be downloaded, and it will take a while. Then CMake loads the default configuration, as shown in the figure below:
insert image description here
the middle part of the window is the configuration list, which is consistent with using the cmake command to directly generate the makefile. As mentioned above, it is more intuitive and convenient to configure through the graphical interface.

6. Two places need to be modified here:

(1) Enter RELEASE at the CMAKE_BUILD_TYPE value, and keep the others unchanged (if it already exists, you don’t need to modify it).
The CMAKE_INSTALL_PREFIX below shows the default installation directory. When the makefile is generated and the make install is finally executed, it will be installed to this directory, which can be changed according to individual needs. I will not make any changes here.
insert image description here

(2) At OPENCV_EXTRA_MODULES_PATH, select the input directory (click the blank space behind this line to select it)
insert image description here
and then select the modules folder in the opencv_contrib-3.2.0 folder. Note that it is not just to select the opencv_contrib-3.2.0 folder Well, you need to select the modules folder inside! As shown in the figure below, then click Choose.
Note: OPENCV_EXTRA_MODULES_PATH is used to specify the extension modules to be compiled, including the OpenCV_contrib module.
insert image description here
7. Click Generate to generate the configuration file, this step should be completed relatively quickly.

8. Next, open the terminal in the build directory and enter

make
sudo make install

9. Then the installation will start, and this step will take a long time...don't worry, this step means that the installation will be successful soon~

insert image description here
In the experiment, I did not compile opencv_contrib-3.2.0, only compiled opencv, but it did compile successfully. This method was also used to compile PCL+VTK before.
It is better to use cmake-gui visual selection, which is better than watching reamde by yourself.

reference

Guess you like

Origin blog.csdn.net/liuqingsongmsdn2014/article/details/131407526