Installation in Linux

These steps have been tested for Ubuntu 10.04 but should work with other distros as well.

Required Packages

  • GCC 4.4.x or later
  • CMake 2.8.7 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 be installed using a terminal and the following commands or by using Synaptic Manager:

  1. [compiler] sudo apt-get install build-essential
  2. [required] sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
  3. [optional] sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

Getting OpenCV Source Code

You can use the latest stable OpenCV version or you can grab the latest snapshot from our Git repository.

Getting the Latest Stable OpenCV Version

Getting the Cutting-edge OpenCV from the Git Repository

Launch Git client and clone OpenCV repository. If you need modules from OpenCV contrib repository then clone it too.

For example

  1. cd ~/<my_working_directory>
  2. git clone https://github.com/Itseez/opencv.git
  3. git clone https://github.com/Itseez/opencv_contrib.git

Building OpenCV from Source Using CMake

  1. Create a temporary directory, which we denote as <cmake_build_dir>, where you want to put the generated Makefiles, project files as well the object files and output binaries and enter there.

    For example

    1. cd ~/opencv
    2. mkdir build
    3. cd build
  2. Configuring. Run cmake [<some optional parameters>] <path to the OpenCV source directory>

    For example

    1. cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..

    or cmake-gui

    • set full path to OpenCV source code, e.g. /home/user/opencv
    • set full path to <cmake_build_dir>, e.g. /home/user/opencv/build
    • set optional parameters
    • run: “Configure”
    • run: “Generate”
  3. Description of some parameters

    • build type: CMAKE_BUILD_TYPE=Release\Debug
    • to build with modules from opencv_contrib set OPENCV_EXTRA_MODULES_PATH to <path to opencv_contrib/modules/>
    • set BUILD_DOCS for building documents
    • set BUILD_EXAMPLES to build all examples
  4. [optional] Building python. Set the following python parameters:

    • PYTHON2(3)_EXECUTABLE = <path to python>
    • PYTHON_INCLUDE_DIR = /usr/include/python<version>
    • PYTHON_INCLUDE_DIR2 = /usr/include/x86_64-linux-gnu/python<version>
    • PYTHON_LIBRARY = /usr/lib/x86_64-linux-gnu/libpython<version>.so
    • PYTHON2(3)_NUMPY_INCLUDE_DIRS = /usr/lib/python<version>/dist-packages/numpy/core/include/
  5. [optional] Building java.

    • Unset parameter: BUILD_SHARED_LIBS
    • It is useful also to unset BUILD_EXAMPLES, BUILD_TESTS, BUILD_PERF_TESTS - as they all will be statically linked with OpenCV and can take a lot of memory.
  6. Build. From build directory execute make, recomend to do it in several threads

    For example

    1. make -j7 # runs 7 jobs in parallel
  7. [optional] Building documents. Enter <cmake_build_dir/doc/> and run make with target “html_docs”

    For example

    1. cd ~/opencv/build/doc/
    2. make -j7 html_docs
  8. To install libraries, from build directory execute

    1. sudo make install
  9. [optional] Running tests

    For example

    1. git clone https://github.com/Itseez/opencv_extra.git
    • set OPENCV_TEST_DATA_PATH environment variable to <path to opencv_extra/testdata>.
    • execute tests from build directory.

    For example

    1. <cmake_build_dir>/bin/opencv_test_core

Note

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

 

【转】linux下安装opencv的更多相关文章

  1. Linux下安装OpenCV+Python支持

    以下说明在Linux下Python和OpenCV结合安装的过程,Python要使用OpenCV模块,则必须导入OpenCV提供的包,所以要提供Python支持,首先在安装OpenCV前安装必要的组件, ...

  2. Python下的OpenCV学习 01 —— 在Linux下安装OpenCV

    一.OpenCV简要介绍 OpenCV是一个跨平台的计算机视觉库,可以运行在Windows.Linux.MacOS等操作系统上.OpenCV提供了众多语言的接口,其中就包含了Python,Python ...

  3. Linux下安装opencv模块

    最近微信上流行的给自己的头像加一顶圣诞帽,想用python写一个程序自己实现一下,其中需要用到opencv import cv2 现在记录一下如何在Linux系统(ubutun)下安装该模块: 参考了 ...

  4. Linux下安装opencv with-ffmpeg解决无法读取视频的问题

    1. 编译安装ffmpeg 下载源码,执行 ./configure --disable-yasm --enbale-shared --prefix=/usr/local/ffmpeg 即可. 2. 下 ...

  5. OpenCV学习一《Linux下安装OpenCV》

    第一步:安装源码前先安装好需要的第三⽅方环境 需要的编译环境■ [compiler] sudo apt-get install build-essential #  注释说明 64位ubuntu在安装 ...

  6. Linux下安装opencv(踩坑记录帖)

    1.首先安装依赖项:sudo apt install build-essential sudo apt install build-essentialsudo apt install cmake gi ...

  7. Ubuntu 14.04 下安装 OpenCV

    参考: Installation in Linux Error compiling OpenCV, fatal error: stdlib.h: No such file or directory 图 ...

  8. centos下安装opencv

    根据项目需要,安装opencv并提供给开发使用,并且使用opencv提供python3的API接口.虽然不知道是个啥,还是简单了解下. opencv是什么? OpenCV的全称是Open Source ...

  9. Mac-OSX的Python3.5虚拟环境下安装Opencv

    Mac-OSX的Python3.5虚拟环境下安装Opencv 1   关键词 关键词:Mac,OSX,Python3.5,Virtualenv,Opencv 2   概述 本文是一篇 环境搭建 的基础 ...

随机推荐

  1. jekyll 的安装

    静态网站生成器Jekyll 是一个简洁的.特别针对博客平台的 静态网站 生成器.它使用一个模板目录作为网站布局的基础框架,并在其上运行 Textile . Markdown 或 Liquid 标记语言 ...

  2. Python3 字符编码

    编码 字符串是一种数据类型,但是,字符串比较特殊的是还有一个编码问题. 因为计算机只能处理数字,如果要处理文本,就必须先把文本转换为数字才能处理.最早的计算机在设计时采用8个比特(bit)作为一个字节 ...

  3. CPU/寄存器/内存

    因为要了解多线程,自然少不了一些硬件知识的科普,我没有系统学习过硬件知识,仅仅是从书上以及网络上看来的,如果有错误请指出来. CPU,全名Central Processing Unit(中央处理器). ...

  4. Javascript 备忘

    1遍历所有属性 var person={fname:"John",lname:"Doe",age:25}; for (x in person) { txt=tx ...

  5. Laravel 安装记录

    系统环境:ubuntu-14.10-server-i386(32) LAMP 系统默认安装 根据:http://laravel.com/docs/5.1  官方文档,准备通过 Composer 安装 ...

  6. 7 -- Spring的基本用法 -- 8...

    7.8 深入理解容器中的Bean 7.8.1 抽象Bean与子Bean 把多个<bean.../>配置中相同的信息提取出来,集中成配置模版------这个配置模版并不是真正的Bean,因此 ...

  7. Quartz2D 备忘 + 学习

    Quartz2D Quartz2D是支持iOS和Mac系统的二维绘制引擎,它可以绘制: 绘制图形(图形,线条,圆等) 绘制文字 绘制/生成图片 读取/生成PDF 截图 Quartz2D主要功能就是以画 ...

  8. 定位 -CLGeocoder - 编码

    #import "ViewController.h" #import <CoreLocation/CoreLocation.h> @interface ViewCont ...

  9. 《Linux命令行大全》系列(一、shell是什么)

    学习 Linux, 从命令开始 图形界面只是让简单事情,更简单 图形化界面能快速处理简单的事情,如打开/关闭文件 然后,随着事务复杂度的提升,图形化界面的操作也就繁琐起来 例如,word中插入一个图片 ...

  10. Android源码学习之装饰模式应用

    首先得了解最基础的装饰器模式 参考 设计模式之八 --- 装饰模式(Decorator) 参考链接:http://blog.csdn.net/cjjky/article/details/7478788 ...