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 Vue3.0 + TypeScript + Vite first experience

Table of contents Project Creation Project Struct...

Example of using JSX to build component Parser development

Table of contents JSX environment construction Se...

Guide to Efficient Use of MySQL Indexes

Preface I believe most people have used MySQL and...

How to use DQL commands to query data in MySQL

In this article, the blogger will take you to lea...

Nginx dynamically forwards to upstream according to the path in the URL

In Nginx, there are some advanced scenarios where...

Detailed explanation of the use of the clip-path property in CSS

Use of clip-path polygon The value is composed of...

MySQL horizontal and vertical table conversion operation implementation method

This article uses examples to illustrate how to i...

Docker-compose creates a bridge, adds a subnet, and deletes a network card

1. Create a docker network card [root@i ~]# brctl...

HTML+CSS to achieve drop-down menu

1. Drop-down list example The code is as follows:...

Detailed steps for deploying Microsoft Sql Server with Docker

Table of contents 1 Background 2 Create a contain...

How to use MySQL DATEDIFF function to get the time interval between two dates

describe Returns the time interval between two da...