【转】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
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 buildConfiguring. 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”
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
[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/
[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.
Build. From build directory execute make, recomend to do it in several threads
For example
make -j7 # runs 7 jobs in parallel
[optional] Building documents. Enter <cmake_build_dir/doc/> and run make with target “html_docs”
For example
cd ~/opencv/build/doc/
make -j7 html_docsTo install libraries, from build directory execute
sudo make install
[optional] Running tests
- Get the required test data from OpenCV extra repository.
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.
【转】linux下安装opencv的更多相关文章
- Linux下安装OpenCV+Python支持
以下说明在Linux下Python和OpenCV结合安装的过程,Python要使用OpenCV模块,则必须导入OpenCV提供的包,所以要提供Python支持,首先在安装OpenCV前安装必要的组件, ...
- Python下的OpenCV学习 01 —— 在Linux下安装OpenCV
一.OpenCV简要介绍 OpenCV是一个跨平台的计算机视觉库,可以运行在Windows.Linux.MacOS等操作系统上.OpenCV提供了众多语言的接口,其中就包含了Python,Python ...
- Linux下安装opencv模块
最近微信上流行的给自己的头像加一顶圣诞帽,想用python写一个程序自己实现一下,其中需要用到opencv import cv2 现在记录一下如何在Linux系统(ubutun)下安装该模块: 参考了 ...
- Linux下安装opencv with-ffmpeg解决无法读取视频的问题
1. 编译安装ffmpeg 下载源码,执行 ./configure --disable-yasm --enbale-shared --prefix=/usr/local/ffmpeg 即可. 2. 下 ...
- OpenCV学习一《Linux下安装OpenCV》
第一步:安装源码前先安装好需要的第三⽅方环境 需要的编译环境■ [compiler] sudo apt-get install build-essential # 注释说明 64位ubuntu在安装 ...
- Linux下安装opencv(踩坑记录帖)
1.首先安装依赖项:sudo apt install build-essential sudo apt install build-essentialsudo apt install cmake gi ...
- Ubuntu 14.04 下安装 OpenCV
参考: Installation in Linux Error compiling OpenCV, fatal error: stdlib.h: No such file or directory 图 ...
- centos下安装opencv
根据项目需要,安装opencv并提供给开发使用,并且使用opencv提供python3的API接口.虽然不知道是个啥,还是简单了解下. opencv是什么? OpenCV的全称是Open Source ...
- Mac-OSX的Python3.5虚拟环境下安装Opencv
Mac-OSX的Python3.5虚拟环境下安装Opencv 1 关键词 关键词:Mac,OSX,Python3.5,Virtualenv,Opencv 2 概述 本文是一篇 环境搭建 的基础 ...
随机推荐
- Linq的简单查询
Ling的简单查询,记在这里防止忘记,以便随时能够查看 List<int> intArr = new List<int>(); || i == select i; List&l ...
- Linux文件3个时间点(access time,modify time,change time)
在Linux中使用stat命令来查看文件的详细信息. 如图所示,会出现3个类型的时间,分别是Access,Modify,Change. access time:表示最后一次访问(仅仅是访问,没有改动) ...
- Python3实现连接SQLite数据库的方法
本文实例讲述了Python3实现连接SQLite数据库的方法,对于Python的学习有不错的参考借鉴价值.分享给大家供大家参考之用.具体方法如下: 实例代码如下: ? 1 2 3 4 5 6 7 8 ...
- 欧几里得旅行商问题 java与c++实现
双调欧几里得旅行商问题是一个经典动态规划问题.<算法导论(第二版)>思考题15-1 旅行商问题描述:平面上n个点,确定一条连接各点的最短闭合旅程.这个解的一般形式为NP的(在多项式时间内可 ...
- js template
http://garann.github.io/template-chooser/ http://www.gbin1.com/technology/javascript/20120917-javasc ...
- jquery mobile backbone
http://www.appliness.com/getting-started-with-html-mobile-application-development-using-jquery-mobil ...
- socket.io
http://www.cnblogs.com/fullhouse/archive/2011/07/18/2109936.html http://www.cnblogs.com/fullhouse/ar ...
- 【BZOJ 3387】 线段树= =
57 跨栏训练为了让奶牛参与运动,约翰建造了 K 个栅栏.每条栅栏可以看做是二维平面上的一条线段,它们都平行于 X 轴.第 i 条栅栏所覆盖的 X 轴坐标的区间为 [ Ai,Bi ], Y 轴高度就是 ...
- Tomcat J2ee 发布步骤
1.找到要发布的工程,并发布到本地tomcat下,测试完全没有问题,找到tomcat下webapps下 并找到该工程,进入该工程目录,全选添加到 drivingSchool.zip 或 drivi ...
- 监控持有sql和被堵塞的sql
Session 1: mysql> start transaction; Query OK, 0 rows affected (0.00 sec) mysql> update Client ...