OpenCV-ubuntu-install
1.安装一些依赖库
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev cmake libswscale-dev libjasper-dev
2.下载源码并编译
opencv的下载地址:http://opencv.org/downloads.html
unzip opencv-x-x-x.zip
cd opencv
mkdir build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j && make install
3.安装和 配置
sudo vi /etc/ld.so.d/opencv.conf
输入:
/usr/local/lib
保存并退出
运行ldconfig使生效
sudo ldconfig
在shell的配置的文件中加入
我使用的是oh-my--zsh,所以在~/.zshrc中加入就可以了
#opencv config
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
4.测试
显示图片
ShowImage.cpp
/**
* File name :ShowImage.cpp
* Author :kangkangliang
* File desc :test Opencv
* Mail :942504876@qq.com
* Create time :2016-07-26
*/ /**
* headfile
*/
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <iterator>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace std;
using namespace cv;
/**
* main function
*/
int
main(int argc,char **argv)
{
/// error way
if (argc < )
cout << "usage :./show image_name" << endl; /// read image from agrv
Mat src = imread(argv[]);
if (!src.data)
{
cout << "read iamge error" << endl;
return -;
} /// show image
imshow("image",src);
waitKey();
return ;
}
make.sh 脚本
#########################################
# File name :make.sh
# Author :liangkangkang
# File desc :compile opencv
# Mail :@qq.comm
# Create time :--
#########################################
#!/usr/bin/bash
#obj = `echo $ | cut -d '.' -f1`
#g++ -Wall -std=c++0x $ -o $obj
g++ -Wall -std=c++0x $ `pkg-config --cflags --libs opencv` -o `echo $ | cut -d '.' -f1`
#./`echo $ | cut -d '.' -f1`
$sh make.sh ShowImage.cpp
$./ShowImage image_name
或者使用cmake来编译
编写CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project( ShowImage )
find_package( OpenCV REQUIRED )
add_executable( ShowImage ShowImage.cpp )
target_link_libraries( ShowImage ${OpenCV_LIBS} )
$cmake .
$make
$./ShowImage image_name
祝你成功,开始OpenCV之旅!!!
note:懒人的话就直接用opencv-install 脚本
OpenCV-ubuntu-install的更多相关文章
- Ubuntu install TensorFlow
/******************************************************************************** * Ubuntu install T ...
- ubuntu install zabbix
ubuntu install zabbix reference1 reference2 some ERRORS raise during install process, may it help. z ...
- Ubuntu install android studio
Ubuntu install android studio 1. 安装 openjdk8,并在配置文件 /etc/profile 中,追加如下内容: sudo aptitude install ope ...
- ubuntu install redis
ubuntu install redis apt-get update apt-get install redis-server redis-server --daemonize yes
- ubuntu install opencv
1. install the newest opencv version pip install opencv-python
- Ubuntu install Docker
首先需要说明的是,根据Docker的官方文档,Docker的安装必须在64位的机子上.这里只说明Ubuntu 14.04与16.04,我成功安装成功过Ubuntu 14.04,16.04还没有测试过, ...
- Ubuntu install g++
We can use two ways to install g++ on Ubuntu. 1. a. sudo apt-get install make gcc g++. b. sud ...
- [Ubuntu] Install teamviewer9 on Ubuntu14.04_x64
The article copied from http://ubuntuhandbook.org/index.php/2013/12/install-teamviewer-ubuntu-1404/ ...
- [Ubuntu] Install subversion1.8 on Ubuntu13.10
Subversion1.8 is difference far away from subversion1.7, here is the steps to install subversion1.8. ...
- Ubuntu Install Chrome Brwoser
在ubuntu下安装chrome浏览器,可以直接从官网下载:http://www.google.cn/intl/zh-CN/chrome/browser/thankyou.html?platform= ...
随机推荐
- VS2010编译Qt程序失败------error LNK1123: 转换到 COFF 期间失败:
error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏使用VS2010编译VC++项目的时候可能会出这个问题. 据说升级到SP1后可能问题解决,但是下载量太大,目前没有得到证实. ...
- Teach Yourself Scheme in Fixnum Days 6 recursion递归
A procedure body can contain calls to other procedures, not least itself: (define factorial (lambda ...
- AspNetPager实现真分页+多种样式
真假分页 分页是Web应用程序中最常用到的功能之一.当从数据库中获取的记录远远超过界面承载能力的时候,使用分页可以使我们的界面更加美观,更加的用户友好.分页包括两种类型:真分页和假分页. 其中假分页就 ...
- iptables 顺序
-A INPUT -s 115.236.6.6/32 -p udp -m udp --dport 111 -j ACCEPT -A INPUT -s 10.175.197.98/32 -p udp - ...
- linux下的shell和脚本
1.各种Unix shell linux下的shell基本是从unix环境中的shell发展而来,贴一下wiki:其中我们常用的,可归类为Bourne Shell(/usr/bin/sh或/bin/s ...
- CentOS6.5下安装wine
系统信息: Centos 6.5 i386 GUN/Linux 1. 首先安装一个epel rpm -ivh http://mirrors.yun-idc.com/epel/6/i386/epel-r ...
- JS监听组合按键
有些时候,我们需要在网页上,增加一些快捷按键,方便用户使用一些常用的操作,比如:保存,撤销,复制.粘贴等等. 下面简单梳理一下思路: 我们所熟悉的按键有这么集中类型: 单独的按键操作,如:delete ...
- thinkphp分页时修改last显示标题
需要修改Page.class.php里lastSuffix为false,这样才能修改last显示标题. 然后就可以设置了 或者直接在方法中声明: $p->lastSuffix = false; ...
- (转)iOS7界面设计规范(4) - UI基础 - 布局
好吧,第四篇的样子,节奏还好:我怎么又是刚吃过小龙虾的状况呢. 今天的话题是布局,篇幅很短:我自己好喜欢这样,在还有些剩余时间和精力的情况下,一个话题一个话题的推进,做做译文,并热切的希望这些内容在自 ...
- 设计: ListView 接口,and the missing read-only interfaces in java collection framework
Java的集合框架以其成功易用的设计征服了很多人(包括我),并且教科书式的诠释了泛型的应用方式. 我也是被 Joshua Bloch 的书引领入门,从中得益良多.我当然不会认为自己在设计上比他懂得更多 ...