1. Install dependencies

Be sure to install them all to avoid all kinds of strange problems later

Sudo apt-get install build-essential sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev  liblapacke-dev sudo apt-get install libxvidcore-dev libx264-dev sudo apt-get install libatlas-base-dev gfortran sudo apt-get install ffmpegCopy the code
  1. Download the opencv and opencv_contrib source files

You are advised to download the.tar.gz file and decompress it. Then place the OpencV_contirb file in the OpencV folder

I’m using version 4.2.0

Notifications · Opencv/Opencv · GitHub notifications · Opencv/Opencv_contrib · GitHub

Tar -zxvf opencv-4.2.0.tar.gz tar -zxvf opencv_contirb-4.2.tar. gz mv Opencv_contirb-4.2.0 / opencv-4.2.0/Copy the code
  1. compile
sudo mkdir build && cd build

sudo cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local- D OPENCV_EXTRA_MODULES_PATH = / Developer/opencv - 4.2.0 / opencv_contrib - 4.2.0 / modules /.. sudo make -j${nproc}

sudo make install
Copy the code

Note that the second step is to change to your own path. The third step ${nproc} is to compile with all CPU cores

GitHub omega-Lee/OpenCV_boostdesc_vgg_file: GitHub omega-Lee/OpenCV_boostdesc_vgg_file Lack of often occurs at the time of compilation of OpenCV. I file, so once they make a collection put the files in the repo opencv_contrib/modules/xfeatures2d/SRC /

Github-opencv: Open Source Computer Vision Library github-OpencV: Open Source Computer Vision Library github-OpencV: Open Source Computer Vision Library

[error: cannot find feature2d/test/test_detectors_regression impl. HPP 】 solution: to compile these files are copied to the folder: cp opencv/modules/features2d build

  1. Configure paths

    1. vim/etc/ld.so.conf.d/opencv.confAt the end of the line/usr/local/lib
    2. ldconfigLet it take effect
    3. vim /etc/bash.bashrcAt the end of the lineexport PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
    4. source /etc/bash.bashrc Update the bash
  2. Pkg-config opencV –modversion check whether the installation is successful

【 错 误 : Package opencV was not found in the PKG-config search path.】

cd /usr/local/lib
sudo mkdir pkgconfig
cd pkgconfig
sudo vim opencv.pc
Copy the code

Add the following information to Opencv. PC

prefix=/usr/local
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib Name: opencv Description: The Opencv library Version:4.2.0 Cflags: -i${includedir}/opencv4
Libs: -L${libdir} -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann  -lopencv_core
~
Copy the code

Export files to environment variables

export  PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
Copy the code

Resources

The feature2d/test/ test_detectorS_register.impl. HPP file _Wenrui cannot be found Xie’s blog -CSDN Blog