How to install the OpenCV in Linux

Source: Internet
Author: User
Tags git client git clone

Installation in Linux

These steps has been tested for Ubuntu 10.04 and should work with other distros as well.

Required Packages

  • GCC 4.4.x or later
  • CMake 2.6 or higher
  • Git
  • gtk+2.x or higher, including headers (Libgtk2.0-dev)
  • Pkg-config
  • Python 2.6 or later and Numpy 1.5 or later with developer packages (Python-dev, python-numpy)
  • FFmpeg or LIBAV development Packages:libavcodec-dev, Libavformat-dev, Libswscale-dev
  • [Optional] libtbb2 Libtbb-dev
  • [Optional] libdc1394 2.x
  • [optional] Libjpeg-dev, Libpng-dev, Libtiff-dev, Libjasper-dev, Libdc1394-22-dev

The packages can installed using a terminal and the following commands or by using Synaptic Manager:

[Compiler] sudo apt-get install build-essential

[Required] sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev Libswscale-dev

[Optional] sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-d EV Libdc1394-22-dev

Getting OpenCV Source Code

You can use the latest stable OpenCV version available in sourceforge or you can grab the latest snapshot from OU R Git repository.

Getting the Latest Stable OpenCV Version

    • Go to our page on Sourceforge;
    • Download the source tarball and unpack it.

Getting the cutting-edge OpenCV from the Git Repository

Launch Git client and clone OpenCV repository

In Linux it can is achieved with the following command in Terminal:

CD ~/<my_working _directory>

git clone https://github.com/Itseez/opencv.git

Building OpenCV from Source using CMake, using the Command line

  1. Create a temporary directory, which we denote as <cmake_binary_dir>, where you want to put the generated makefiles, Project files as well the object files and output binaries.
  2. Enter the <cmake_binary_dir> and type
  3. CMake [<some optional parameters>] <path to the OpenCV source directory>

    For example

    CD ~/OPENCV

    mkdir Release

    CD release

    Cmake-d cmake_build_type=release-d cmake_install_prefix=/usr/local.

  4. Enter the created temporary directory (<cmake_binary_dir>) and proceed with:
  5. Make
  6. sudo make install

Note

If the size of the created library is a critical issue (as in case of an Android build) you can use the Install/strip Co Mmand to get the smallest size as possible. The stripped version appears to be twice as small. However, we do not recommend using the unless those extra megabytes do really matter.

How to install the OpenCV in Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.