How to compile and install opencv under ubuntu

How to compile and install opencv under ubuntu

Easy installation of opencv2:

conda install --channel https://conda.anaconda.org/menpo opencv

or:

sudo apt-get install libopencv-dev python-opencv

Easy installation of opencv3:

pip install opencv-python

or:

pip install opencv-python==3.1.0

The simple installation method is to install the compiled Opencv from the library. This installation method is simple and convenient. The disadvantage is that it is easy to have unknown bugs during use, such as not being able to imshow images, not being able to read video files, etc. (opencv3 seems to be better).

It is recommended to compile and install from source code.

Compile and install Opencv2 or Opencv3 from source code

1. Install dependency files

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

2. Download the source package

Official website download address: https://opencv.org/opencv-3-2.html

Here, choose to download the tar.gz file for all platforms on the GitHub source (download link: https://github.com/opencv/opencv/archive/3.2.0.tar.gz), opencv-3.2.0.tar.gz, file size 75MB

3. Unzip the source code and compile and install

tar xvf opencv-3.2.0.tar.gz
cd opencv-3.2.0
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install

Note: When executing the cmake command, you need to download a ippicv_linux_20151201.tgz file. If the network is not good, it may get stuck at:

ICV: Downloading ippicv_linux_20151201.tgz...

At this time, you can download the ippicv_linux_20151201.tgz file separately (file size 36.5MB, download link: https://raw.githubusercontent.com/Itseez/opencv_3rdparty/81a676001ca8075ada498583e4166079e5744668/ippicv/ippicv_linux_20151201.tgz), put it in the '/opencv-3.2.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/' folder after downloading, and then re-cmake it.

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • VS2015+Qt5+OpenCV3 development environment configuration
  • OpenCV 3.1.0+VS2015 development environment configuration tutorial
  • Graphical tutorial on OpenCV configuration method under VS2015
  • Detailed process of configuring Opencv3.1.0 in vs2015 under win10
  • Detailed steps to compile and install opencv from source code on Ubuntu 17.04
  • Tutorial on compiling opencv249 with C++ vs2015 under win10 environment

<<:  How to configure the My.ini file when installing MySQL5.6.17 database

>>:  jQuery plugin to implement dashboard

Recommend

Detailed explanation of software configuration using docker-compose in linux

Preface This article will share some docker-compo...

Why is the MySQL auto-increment primary key not continuous?

Table of contents 1. Introduction 2. Self-increme...

Detailed process of installing and configuring MySQL and Navicat prenium

Prerequisite: Mac, zsh installed, mysql downloade...

A friendly alternative to find in Linux (fd command)

The fd command provides a simple and straightforw...

Disadvantages and reasonable use of MySQL database index

Table of contents Proper use of indexes 1. Disadv...

Diagram of the process of implementing direction proxy through nginx

This article mainly introduces the process of imp...

How to deal with too many Docker logs causing the disk to fill up

I have a server with multiple docker containers d...

Semantic web pages XHTML semantic markup

Another important aspect of separating structure ...

Implementation of Docker deployment of SQL Server 2019 Always On cluster

Table of contents Docker deployment Always on clu...

JavaScript to implement dynamic digital clock

This article shares the specific code for impleme...