// linux opencv安装及初试
// 2015.11.20 created by Huangtao

官方教程:
=========
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.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 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 available in sourceforge or you can grab the latest snapshot from our 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 be 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
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.

Enter the <cmake_binary_dir> and type

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 ..
Enter the created temporary directory (<cmake_binary_dir>) and proceed with:

make
sudo make install
Note If the size of the created library is a critical issue (like in case of an Android build) you can use the install/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
------------------------------------------------------------------------------------

我在ubuntu14上的成功安装方法:
=============================
安装官方教程,先安装依赖库:
apt-get install build-essential
apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
接下来,自己也编译过,但最后都失败。
所以最后就直接利用:
apt-get install libopencv-dev
查看版本号:
pkg-config --modversion opencv
2.4.8
理论上opencv安装好了,应出现以下文件:
在/usr/local/lib应该出现以下链接库:
libcvaux.so -> libcvaux.so.2.0
libcvaux.so.2.0 -> libcvaux.so.2.0.0
libcvaux.so.2.0.0
libcv.so -> libcv.so.2.0
libcv.so.2.0 -> libcv.so.2.0.0
libcv.so.2.0.0
libcxcore.so -> libcxcore.so.2.0
libcxcore.so.2.0 -> libcxcore.so.2.0.0
libcxcore.so.2.0.0
libhighgui.so -> libhighgui.so.2.0
libhighgui.so.2.0 -> libhighgui.so.2.0.0
libhighgui.so.2.0.0
libml.so -> libml.so.2.0
libml.so.2.0 -> libml.so.2.0.0
libml.so.2.0.0
在/usr/local/include/opencv或opencv2应该出现以下头文件:
cvaux.h, cvcompat.h, cv.hpp, cvver.h, cvwimage.h, cxcore.hpp, cxflann.h,
cxmisc.h, cxtypes.h, highgui.hpp, cvaux.hpp, cv.h, cvtypes.h, cvvidsurv.hpp,
cxcore.h, cxerror.h, cxmat.hpp, cxoperations.hpp, highgui.h, ml.h
不过在我的目录下只有头文件没有链接文件,
/usr/include/下有opencv和opencv2
/usr/local/include/也有opencv和opencv2,但opencv下是空的。
不过测试程序还是可以运行的。
编译:
g++ `pkg-config --cflags opencv` main.cpp `pkg-config --libs opencv` -o main

我在树莓派上安装opencv;
=======================
安装好镜像正常启动后,
添加apt-get源:
nano /etc/apt/sources.list
删除原文件所有内容,用以下内容取代:
deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ wheezy main non-free contrib
deb-src http://mirrors.ustc.edu.cn/raspbian/raspbian/ wheezy main non-free contrib

apt-get update
apt-get install build-essential
apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
apt-get install libopencv-dev
查看版本:
pkg-config --modversion opencv
2.4.1
插入U盘:在我的树莓派上,/media/下出现U盘,复制已经写好的源文件和jpg图片。
编译:
g++ `pkg-config --cflags opencv` main.cpp `pkg-config --libs opencv` -o main
运行:
./main
正常,运行成功!

转载于:https://www.cnblogs.com/ht-beyond/p/4989739.html

OpenCV在Linux上的安装及初试相关推荐

  1. redis在Linux上的安装

    1.redis在Linux上的安装 1)安装redis编译的c环境,yum install gcc-c++ 2)将redis-2.6.16.tar.gz上传到Linux系统中 3)解压到/usr/lo ...

  2. linux能安装音乐软件吗,Linux上如何安装使用音乐软件SoundCloud

    Linux上如何安装使用音乐软件SoundCloud 卡饭网 梦在深巷 2015-02-13 18:16:08 对于喜欢音乐的朋友来说,SoundCloud是个不错的音乐软件,SoundCloud是德 ...

  3. Linux入门第五集!MySQL8在Linux上的安装!MySQL的Linux资源分享!

    Linux入门第五集!MySQL8在Linux上的安装!MySQL的Linux资源分享! 一.Mysql的Linux版本下载! 博主采用的是mysql-8.0.25-1.el7.x86_64.rpm- ...

  4. linux系统无线驱动在哪下载,在linux上怎么安装无线网卡驱动?

    在linux上怎么安装无线网卡驱动? 在linux上安装无线网卡驱动的方法: (1)先确定无线网卡型号,因驱动安装和型号是密切相关的,不同的型号,安装和下载驱动有所不同,但原理是一样的.图例为无线网卡 ...

  5. ubuntu intellij java_在Linux上,安装Intellij IDEA进行Scala开发

    2016年4月27日 通过瑞雷斯·艾奥阿尼 介绍 Scala是一种编程语言,最近几年开始蓬勃发展.在撰写本文时,流行的TIOBE Index将其排名为比Haskell或Go等更流行的语言更常用.如果您 ...

  6. linux mint python3.6,Linux 上如何安装并切换最新版本的 Python 3.6

    原标题:Linux 上如何安装并切换最新版本的 Python 3.6 如果你安装了 Linux 系统,正在学习 Python 并想要使用最新的版本的话,那么这篇文章就是为你而写的. -- Shekin ...

  7. 在linux环境下启动es,linux上Elasticsearch 安装配置、网页访问

    一.ElasticSearch简述 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口.Elasticsearch ...

  8. redis系列之1----redis简介以及linux上的安装

    redis简介 redis是NoSQL(No Only SQL,非关系型数据库)的一种,NoSQL是以Key-Value的形式存储数据.当前主流的分布式缓存技术有redis,memcached,ssd ...

  9. Linux上快速安装软RAID详细步骤

    物理环境:虚拟机CentOS6.4 配置:8G内存.2*2核cpu.3块虚拟硬盘(sda,sdb,sdc,sdb和sdc是完全一样的) 在实际生产环境中,系统硬盘与数据库和应用是分开的,这样有利于系统 ...

最新文章

  1. SpringBoot自适应异常处理
  2. matlab 数组元素连乘积prod
  3. secondarynamenode异常
  4. Windows API 逐个逐个学(3)----Windows系统基本服务API GetSystemDirectory
  5. 工作中git常用命令
  6. docker打包部署nginx,django应用
  7. 趋势预测算法大PK!
  8. 做了三年前端开发后,我选择回家创业
  9. 【博学谷学习记录】超强总结,用心分享|Java基础语法week2
  10. 威斯敏斯特教堂(西敏寺)墓碑上的话(WestMinster Abbey,When I was young and free...,修身齐家治国平天下)...
  11. 485的信号测试软件,RS485通信测试项目中的压力测试方法、原理及基本测试模型...
  12. 内向的人和陌生人聊天,如何做到有话可说
  13. (转)为什么证券行业的软件研发水平远低于互联网科技公司?
  14. 《从零开始的 RPG 游戏制作教程》第十二期:刷怪与防守(上)
  15. 猫眼 — 破解数字反爬获取实时票房
  16. REMOTE HOST IDENTIFICATION HAS CHANGED问题解决
  17. 2015年1月9日XX大学XX学院考试题
  18. PDPS软件:机器人固定点焊虚拟仿真操作方法
  19. ES5和ES6的类,静态方法,继承实现代码
  20. UR机器人PolyScope使用入门教程

热门文章

  1. js为操作radio
  2. 【高斯和拉普拉斯为什么分别对应L2和L1?】差分隐私系统学习记录(五)
  3. Multi-thread--C++11中atomic的使用
  4. 基于同步视频的视野分界线划分算法
  5. 主分区活动分区扩展分区逻辑分区
  6. Ubuntu搜狗输入法安装
  7. 加加速度matlab,关于加加速度的若干机械运动分析及MATLAB模拟
  8. 基于深度学习的文本分类1
  9. Golang基本变量
  10. python爬虫之request_Python爬虫:Scrapy研读之Request/Reponse