Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Resolving Common Issues During OpenCV 3.1.0 Installation

Tech 1

Dependency Setup

Initial attempt to install required packages may fail:

sudo apt-get install build-essential libgtk2.0-dev libvtk5-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev libtbb-dev

A correction involves updating package versions and adddressing a missing component:

sudo apt-get install build-essential libgtk2.0-dev libvtk6-dev libjpeg-dev libtiff5-dev libjasper-dev libopenexr-dev libtbb-dev

If the libjasper-dev package remains unfound, resolve by enabling the Ubuntu security repository:

  1. Edit the sources list:
    sudo vim /etc/apt/sources.list
    
  2. Append the following line at the end:

deb http://security.ubuntu.com/ubuntu xenial-security main

3. Save the file and update the package cache:
```bash
sudo apt-get update
  1. Verify the package availability:
    apt-cache search libjasper-dev
    
  2. Install the package:
    sudo apt-get install libjasper-dev
    

Now, re-run the corrected dependency installation command.

Source Acquisition

Obtain the OpenCV 3.1.0 source archive from the official GitHub Releases page and extract it too a working directory.

Build Configuration

Navigate to the extracted source directory and create a build folder:

mkdir build
cd build

Configure the build with CMake. Specify a custom installation directory to avoid conflicts:

cmake -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_INSTALL_PREFIX=/opt/opencv-3.1.0 \
      -DENABLE_PRECOMPILED_HEADERS=OFF \
      -DBUILD_opencv_python2=OFF \
      -DBUILD_opencv_python3=OFF ..

Note on ippicv: If the configuration stalls due to a slow donwload of the ippicv library, manually download ippicv_linux_20151201.tgz from the official OpenCV third-party repository. Place the downloaded file in the corresponding local directory within the source tree (e.g., opencv-3.1.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/).

Compilation

Compile the library using multiple cores:

make -j4

If compilation fails, check for specific errors.

Macro Definition Fix

An error regarding missing FFmpeg macros might occur. Add the following definitions to opencv-3.1.0/modules/videoio/src/cap_ffmpeg_impl.hpp:

#define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22)
#define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER
#define AVFMT_RAWPICTURE 0x0020

Duplicate Symboll Fix

A late-stage error about a duplciate constant (l_MAGIC_VAL) can be resolved by ensuring Python bindings are disabled, which is already handled in the CMake command above.

After successful compilation, install the library:

sudo make install

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.