【转】linux下安装opencv

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:

[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-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

  • Go to our downloads page.
  • Download the source archive and unpack it.

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

cd ~/<my_working_directory>
git clone https://github.com/Itseez/opencv.git
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

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

    For example

    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

    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

    cd ~/opencv/build/doc/
    make -j7 html_docs
    
  8. To install libraries, from build directory execute
    sudo make install
    
  9. [optional] Running tests

    For example

    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

    <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.

时间: 2024-10-07 15:36:55

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

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

1. 编译安装ffmpeg 下载源码,执行 ./configure --disable-yasm --enbale-shared --prefix=/usr/local/ffmpeg 即可. 2. 下载opencv并设置config 下载源码,并 git checkout 3.1.0,也可以是其他版本 cmake -D WITH_CUDA=OFF -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/home/packages/opencv/i

Linux下安装并使用Java开发opencv的配置

inux编译安装opencv 首先, linux下安装opencv其实不麻烦的, 参考文档即可完成: http://docs.opencv.org/trunk/doc/tutorials/introduction/linux_install/linux_install.html 大致有以下几个步骤: 1) 安装gcc以及cmake等等乱七八糟的软件(不过ubuntu下默认差不多都有了吧…) sudo apt-get install build-essential python-dev cmake

如何配置linux下的opencv

方法一: 搜索当前的linux下的opencv支持的版本,我的是14.04为2.3版本. $ apt-cache search opencv 安装下面三个,用来运行OpenCV程序: apt-get install libcv2.3 libcvaux2.3libhighgui2.3 使用OpenCV来编写程序: apt-get install libcv-dev libcvaux-devlibhighgui-dev 方法二: 在Ubuntu的软件中心中有opencv的安装包,可以点击相应的安装包

linux 下安装编译配置 QT

打算做嵌入式图像处理,计划方案嵌入式Linux+OpenCV+QT,昨天简单入门OpenCV今天看看QT,QT就先弄Linux下面的,回家之前争取把基本的摸通,然后能在板子上跑起来. 软件环境 Linux:Ubuntu 12.04 X86 QT:4.8.4 关于QT安装 QT的早期版本和现在版本有点变化,提供的文件也不尽相同,最新的版本为5.0,我这里用的是4.8.4,一个完整的QT应该包括QT库.IDE也就是QT creator,在Linux下的安装中,目前看到的主要有三种方法: 1..bin

Linux下安装禅道管理系统7.2

提示:禅道是用PHP开发的,只要安装一个MySQL,找一个能跑PHP的web应用服务器,把禅道源代码放到里面,然后按步骤安装就可以了.不一定要用XAMPP,XAMPP只是把PHP环境和MySQL都集成了而已. 禅道简介 禅道项目管理软件(ZenTaoPMS)是一款国产的,基于ZPL协议,开源免费的项目管理软件,它集产品管理.项目管理.测试管理于一体,同时还包含了事务管理.组织管理等诸多功能,是一款功能完备的项目管理软件,完美地覆盖了项目管理的核心流程,是中小型企业项目管理的首选. 禅道项目管理软

Linux下安装搭建Memcached集群环境

Linux下安装搭建Memcached集群环境

FFmpeg在Linux下安装编译过程

转载请把头部出处链接和尾部二维码一起转载,本文出自:http://blog.csdn.net/hejjunlin/article/details/52402759 今天介绍下FFmpeg在Linux下安装编译过程,用的是CentOS, 总体过程比较顺利,就是在ffmpeg等的时间稍长点.没什么技术难点.仅当记录. 关于FFmpeg FFmpeg是一个开源免费跨平台的视频和音频流方案,属于自由软件,采用LGPL或GPL许可证(依据你选择的组件).它提供了录制.转换以及流化音视频的完整解决方案.它包

Linux下安装配置Apache服务器

Linux下安装配置Apache服务器 1. 安装Apache [[email protected] ~]# yum –y install httpd 2. 启动Apache [[email protected] ~]# systemctl start httpd 3. 查看进程 [[email protected] ~]# systemctl status httpd httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib

linux 下安装 mysql 并配置 python 开发环境

1.安装 mysql ,安装过程中将提示设置 root 用户的密码,默认可以设置为 rootadmin . $ sudo apt-get install mysql-server 2.安装 mysql 开发工具(不安装时,安装 MySQL-python 提示错误 "mysql_config not found"). $ sudo apt-get install libmysqld-dev 3.安装 python 的 mysql 库 MySQL-python (首先安装 python-d