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
general github slow hang a ladder, slow to download Thunder.
2. computer into a server or extract the target directory
- To the corresponding directory
unzip 3.4.6.zip
- 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 ..
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
sudo make install
- 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)
5. makefile
- Into the doc folder
cd doc
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
opencv_contrib-3.4.6
- URL: https://github.com/opencv/opencv_contrib/releases
the same process, just unzip to "opencv-3.4.6" folder to go through unzip.
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.
Replication method
2⃣️ for opencv2 / xfeatures2d / cuda.hpp: No such file or directory solution to the problem of class
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 make
complete execution.
- at last!
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!