linux installation configuration opencv3.4.6 + opencv_contrib3.4.6

Website: https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html
[official website, there is a problem watching this]

Reference: https://blog.csdn.net/qq_37027117/article/details/89163596
Xiongtai give a lot of help, but when some of the details of the steps that I performed some problems, so there will be a lot of different places.

opencv

1. Download the specified version of opencv for linux

https://github.com/opencv/opencv/releases
Here Insert Picture Description
general github slow hang a ladder, slow to download Thunder.
Here Insert Picture Description

2. computer into a server or extract the target directory

  • To the corresponding directory
unzip 3.4.6.zip

Here Insert Picture Description

  • Enter the directory
cd opencv-3.4.6
  • Create a folder called build
mkdir build

3. cmake

  • Go into a folder inside
cd build
  • Configuration cmake
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/opencv346 -DPYTHON_DEFAULT_EXECUTABLE=$(which python3) -DWITH_TBB=ON -D WITH_EIGEN=ON ..

Here Insert Picture Description
The main function is configuration, and generate output file to a specified location.
(Behind -D do not add a space, or there will not be found error directory)

4. make instruction

sudo make

Here Insert Picture Description

sudo make install

Here Insert Picture Description

  • Make to improve execution speed by this host on a multi-core instruction, while allowing that the parallel task 7
make -j7

(The following is the official website of the original words)
Here Insert Picture Description

5. makefile

  • Into the doc folder
cd doc

Here Insert Picture Description

make -j7 doxygen

6. Set Environment Variables

  • Switch to superuser
sudo su
  • To modify the configuration by superuser privileges
vi /etc/ld.so.conf.d/opencv.conf

Add at the end of the file: / usr / local / opencv346 / lib (possibly empty file)

  • Open vim again
vi /etc/bash.bashrc
  • In the end of the file add:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opencv346/lib/pkgconfig
export PKG_CONFIG_PATH

After restarting the terminal configuration, the configuration.
Or execution:

source /etc/bash.bashrc
sudo updatedb
  • You can check out if there is a successful installation, if successful, is shown below
ldconfig -v | grep opencv

Here Insert Picture Description

opencv_contrib-3.4.6

cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/opencv346 -DPYTHON_DEFAULT_EXECUTABLE=$(which python3) -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-3.4.6/modules -DWITH_TBB=ON -DWITH_EIGEN=ON ..

(Because my server, python3 position is to turn over, so I write, as follows)

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/opencv346 -DPYTHON_DEFAULT_EXECUTABLE=$(which /usr/bin/python3) -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-3.4.6/modules -DWITH_TBB=ON -DWITH_EIGEN=ON ..
sudo make

Among them, you will encounter two types of problems:

1⃣️ prompted to install OpenCV lack boostdesc_bgm.i document solutions to problems (with resources)

The main problem solutions are written very clearly that this is not repeated.
Here Insert Picture Description
Replication method
Here Insert Picture Description

2⃣️ for opencv2 / xfeatures2d / cuda.hpp: No such file or directory solution to the problem of class
Here Insert Picture DescriptionHere Insert Picture Description
to "opencv2 / xfeatures2d / nonfree.hpp" for example, the absolute path is:

/home/liu/Dear/opencv-3.4.6/opencv_contrib-3.4.6/modules/xfeatures2d/include/opencv2/xfeatures2d/nonfree.hpp

We continue to sudo makecomplete execution.

  • at last!
    Here Insert Picture Description

Next

sudo make install

The installation is complete!


Start detection using opencv

cd /home/liu/Dear/opencv-3.4.6/samples/cpp/example_cmake
cmake .
make

Because I do not call it a camera, so the display build but did not catch. But it is ok to install it!Here Insert Picture Description

Published 22 original articles · won praise 18 · views 7170

Guess you like

Origin blog.csdn.net/weixin_43525427/article/details/104180404
Recommended