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= ...
随机推荐
- bzoj 2075: [POI2004]KAG
整天鬼畜题搞搞,感觉药丸…… 这种题出到xjoi模拟题里,太神了…… 这题的核心在于分割Cograph,尝试把Cograph的合成过程给求出来. 我们将这张图中的边为黑边,在这张图的补图中出现的边为白 ...
- 封装JDBC事务操作,执行存储过程测试
Oracle数据库端测试环境见:http://www.cnblogs.com/yshyee/p/4392328.html package com.mw.utils; import java.sql.C ...
- Ubuntu12.04 下配置tomcat
首先要配置好JDK,参考:http://www.cnblogs.com/yshyee/p/3352154.html 到http://tomcat.apache.org/download-60.cgi下 ...
- cf B. Dima and Text Messages
http://codeforces.com/contest/358/problem/B 先按照题意说的构造一个字符串s,然后与对比的字符串T比较,看看在字符串T中顺序查找有没有字符串S的所有字符,有输 ...
- hdu Number Sequence
这道题是寻找规律.别的方法一般都是超时. #include <cstdio> #include <cstring> #include <algorithm> usi ...
- scheme 解释器Guile 使用
GNU Guile是一种Scheme编程语言的解释器和虚拟机.Guile是GNU Ubiquitous Intelligent Language for Extensions的缩写.Guile是GNU ...
- Linux 让进程在后台可靠运行的几种方法
我们经常会碰到这样的问题,用 telnet/ssh 登录了远程的 Linux 服务器,运行了一些耗时较长的任务, 结果却由于网络的不稳定导致任务中途失败.如何让命令提交后不受本地关闭终端窗口/网络断开 ...
- Resty 一款极简的restful轻量级的web框架
https://github.com/Dreampie/Resty Resty 一款极简的restful轻量级的web框架 开发文档 如果你还不是很了解restful,或者认为restful只是一种规 ...
- 【转】Devexpress使用之:GridControl控件(合并表头)
Devexpress系列控件功能很强大,使用起来也不太容易,我也是边摸索边使用,如果有时间我会把常用控件的使用方法整理出来的. using System; using System.Collectio ...
- 使用markdown语法撰写csdn博客
在CSDN之下写blog无疑是一件非常吃力的事情,对于非常多simple爱好者来讲,能用markdown语法来书写代码是最优雅简洁只是的了.本文主要介绍markdown语法和怎样它来撰写csdn下的b ...