Compile opencv on uos

Author: Zhu Jincan
Source: clever101's column

Download source code and create build folder

The system environment is the operating system: UnionTech OS Server 20 Enterprise, and the processor: Huawei Kunpeng processor (arm architecture). Place the source code in the /home/ThirdPartySrc/opencv-4.5.0 directory, and then enter the directory:

cd /home/ThirdPartySrc/opencv-4.5.0
mkdir -p build && cd build

Execute the cmake command to configure compilation options

The cmake compilation options are as follows

"/home/soft/cmake-3.26.3-linux-aarch64/bin/cmake"  .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON \
-DCMAKE_INSTALL_PREFIX=/opt/ThirdPartyLib/opencv-4.5.0 \
-DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.5.0/modules \
-DOPENCV_ENABLE_NONFREE=ON ENABLE_CXX11=ON -DBUILD_opencv_python3=OFF \
-DWITH_1394=OFF -DWITH_IPP=OFF -DWITH_TBB=OFF \
-DWITH_OPENMP=OFF -DWITH_PTHREADS_PF=ON -DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF -DOPENCV_GENERATE_PKGCONFIG=ON \
-DWITH_CUDA=OFF -DENABLE_FAST_MATH=OFF -DCUDA_FAST_MATH=OFF \  
-DWITH_CUBLAS=OFF

The compilation options are described as follows:
"/home/soft/cmake-3.26.3-linux-aarch64/bin/cmake" is the absolute path of the cmake program,
CMAKE_BUILD_TYPE=Release: do not include debugging information in the generated library file, and optimize the speed . If you specify Debug, you can enter the code inside OpenCV during the Debug process, but the running speed will decrease slightly.
CMAKE_VERBOSE_MAKEFILE=ON: Be sure to turn it on, so as to find problems in compilation.
CMAKE_INSTALL_PREFIX=/usr/local: Specify the installation path of the library files generated by OpenCV in the system.
BUILD_SHARED_LIBS=ON: Create a shared library (.so), if it is set to OFF, only a static library (.a) will be generated
OPENCV_EXTRA_MODULES_PATH=<opencv-contrib directory>, according to the previous description, it should be ".../.../opencv_contrib-4.3 .1". You can use the ls command to confirm whether the relative path exists.
OPENCV_ENABLE_NONFREE=ON: If it is set to OFF, some functions containing patent protection algorithms will not be generated.
ENABLE_CXX11=ON: Support C++11 and above syntax and STL library.
BUILD_TESTS=OFF, BUILD_PERF_TESTS=OFF: Turn off the generated self-TEST, which is unnecessary in most cases and can greatly shorten the generation time. But if you suspect a problem with the generated OpenCV library, you can test yourself.
OPENCV_GENERATE_PKGCONFIG=ON: It is recommended to enable it, so that C++ programs can refer to the OpenCV library through pkg-config.
WITH_CUDA=ON, ENABLE_FAST_MATH=ON, CUDA_FAST_MATH=ON, WITH_CUBLAS=ON: If the system has CUDA installed correctly and you want OpenCV to enable CUDA support, all four options should be turned on.
WITH_IPP=ON, WITH_TBB=ON, WITH_OPENMP=ON, WITH_PTHREADS_PF=ON: These four options control how OpenCV performs concurrent operations. The default is ON, but if you need to generate an OpenCV that is absolutely single-threaded, please set these options are set to OFF.

execute compile

Compile command:

make install -j$(grep -c ^processor /proc/cpuinfo)

The generated library files can be downloaded here: Library files and header files of opencv 4.5 compiled on uos

problems and solutions

Warnings appear during compilation: xfeatures2d/vgg: download failed: 28; "timeout was reached" and other warnings. The
reason is that the download of boostdesc_bgm.i and boostdesc_bgm_bi.i failed. Please refer to Reference 2 for specific solutions.

references:

1. Compile OpenCV and openc_contrib prompts to solve the missing boostdesc_bgm.i file error
2. Compile and install OpenCV in the Linux system

Guess you like

Origin blog.csdn.net/clever101/article/details/130159763