This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Read our privacy policy

Compiling OpenCV 4.4.0 on openEuler

Aug 13, 2021

Open Source Computer Vision Library (OpenCV) is a cross-platform computer vision and machine learning software library that is licensed and distributed under a BSD license and can be used free of charge in commercial and research fields.

OpenCV is written in C++ and C languages, has interfaces such as C++, Python, Java, C#, Ruby, Go, and MATLAB, and supports operating systems such as Windows, Linux, Android, and macOS. OpenCV can be used to develop real-time image processing, computer vision, and pattern recognition programs.

OpenCV 4.4.0

On July 18, 2020, OpenCV released its latest version OpenCV 4.4.0 on its official website. The updates in the new version are as follows:

1. SIFT Algorithm Update

The Scale-Invariant Feature Transform (SIFT) algorithm is moved to the primary repository and can be used free of charge. (The SIFT patent has expired.)

2. DNN Module Update

  • Improved layer, activation, and support for more models:

    • Supports the latest Yolov4: #17148.
    • ONNX: supports Resnet_backbone (Torchvision) #16887
    • Supports the EfficientDet model: #17384
  • New demo:

    • Added text recognition example: C++/Python
    • Supports FlowNet2 optical flow: #16575
  • Intel inference engine backend:

    • Supports OpenVINO 2020.3 LTS/2020.4.
    • Planned to remove the support for NN Builder API in the next release.
  • A large number of CUDA support and optimization

    3. G-API Module

  • Introduced new API for the state kernel, GAPI_OCV_KERNEL_ST, to the OpenCV backend.
  • Added video-oriented operations to the G-API module: goodFeaturesToTrack, buildOpticalFlowPyramid, and calcOpicalFlowPyrLK.
  • Added the image processing kernel: Laplacian and bilateral filters.
  • Fixed a potential crash in the G-API's OpenCL backend.

    4. Other Updates

  • Obj-C/Swift binding: #17165
  • BIMEF: biologically inspired multi-exposure fusion framework for image enhancement in low light conditions
  • Added Stroke Width Transform (SWT) to text detection
  • ...

In addition, OpenCV 3.4.11 has been released with some bug fixes and improvements. For details, see the update description at https://github.com/opencv/opencv/wiki/ChangeLog.

This version update also releases a significant signal that OpenCV plans to migrate the authorization protocol from BSD 2 to Apache 2 in the next release, which will eliminate the potential patent risks that OpenCV may face when it is used for commercial products and be more friendly to developers.

Building OpenCV 4.4.0 on openEuler

The following describes the process of building OpenCV 4.4.0 on openEuler and records some troubles encountered and the troubleshooting guide.

Create a folder.

cd /usr/local/src
mkdir opencv
cd opencv

Obtain the OpenCV-4.4.0 source code package from the OpenCV community.

wget https://github.com/opencv/opencv/archive/4.4.0.tar.gz

Decompress the package and create the build folder.

tar -zxvf 3.0.0.tar.gz
cd opencv-3.0.0/
mkdir build
cd build/

Run the cmake command for compilation and build.

cmake ..
make -j8
make install

View the library files and header files generated during OpenCV installation.

ll /usr/local/lib

total 36M -rw------- 1 root root 563K Jul 22 00:31 libade.a lrwxrwxrwx 1 root root 24 Jul 22 01:57 libopencv_calib3d.so -> libopencv_calib3d.so.4.4 lrwxrwxrwx 1 root root 26 Jul 22 01:57 libopencv_calib3d.so.4.4 -> libopencv_calib3d.so.4.4.0 -rwx------ 1 root root 1.9M Jul 22 01:57 libopencv_calib3d.so.4.4.0 lrwxrwxrwx 1 root root 21 Jul 22 00:40 libopencv_core.so -> libopencv_core.so.4.4 lrwxrwxrwx 1 root root 23 Jul 22 00:40 libopencv_core.so.4.4 -> libopencv_core.so.4.4.0 -rwx------ 1 root root 5.2M Jul 22 00:40 libopencv_core.so.4.4.0 lrwxrwxrwx 1 root root 20 Jul 22 01:44 libopencv_dnn.so -> libopencv_dnn.so.4.4 lrwxrwxrwx 1 root root 22 Jul 22 01:44 libopencv_dnn.so.4.4 -> libopencv_dnn.so.4.4.0 -rwx------ 1 root root 5.4M Jul 22 01:44 libopencv_dnn.so.4.4.0 lrwxrwxrwx 1 root root 27 Jul 22 01:50 libopencv_features2d.so -> libopencv_features2d.so.4.4 lrwxrwxrwx 1 root root 29 Jul 22 01:50 libopencv_features2d.so.4.4 -> libopencv_features2d.so.4.4.0

Troubleshooting Guide

During the build, you may encounter the following troubles:

  1. There is no CMake or the CMake version is earlier than the required version.

When the compilation starts, a message is displayed, indicating that the CMake is missing. If the build fails, check whether the CMake version is too early. For example, the CMake version is 3.5.1, which is too early. The CMake version must be 3.14 or later. In this case, you need to reinstall the CMake of a later version. The procedure is as follows:

Obtain the cmake-3.17.2 source code package.

cd /usr/local/src
wget https://cmake.org/files/v3.17/cmake-3.17.2.tar.gz

If the download speed from the CMake official website is slow, you can find the CMake software package that adapts to the openEuler in the src-openEuler project provided by Gitee https://gitee.com/src-openeuler/cmake; download address: https://gitee.com/src-openeuler/cmake/blob/master/cmake-3.17.2.tar.gz.

Decompress the package and go to the installation directory.

cd /usr/local/src
tar -zxvf cmake-3.17.2.tar.gz
cd cmake-3.17.2

Install CMake.

./configure
make
make install

Check whether CMake is installed.

cmake -version

If the following information is displayed, the installation is complete:

cmake version 3.17.2 CMake suite maintained and supported by Kitware (kitware.com/cmake). 2. A message is displayed, indicating that OpenSSL is missing.

During build using CMake, a message is displayed indicating that OpenSSL is missing.

CMake Error: Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY)

Go to the specified directory and download and install the OpenSSL.

cd /usr/local/src
wget https://www.openssl.org/source/openssl-1.1.1f.tar.gz

If the download speed from the OpenSSL official website is slow, you can find the OpenSSL software package that adapts to the openEuler in the src-openEuler project provided by Gitee [https://gitee.com/src-openeuler/openssl](https://gitee.com/src-openeuler/openssl; download address: https://gitee.com/src-openeuler/openssl/blob/master/openssl-1.1.1f.tar.gz.

Decompress the package and go to the installation directory.

tar -xvf openssl-1.1.1f.tar.gz
cd openssl-1.1.1f

Install OpenSSL.

./config
make
make install

Check whether OpenSSL is installed.

openssl -version

OpenSSL 1.1.1f

References:

  1. https://github.com/opencv/opencv/wiki/ChangeLog