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= ...
随机推荐
- PYTHON线程知识再研习E---条件变量同步Condition
Python提供的Condition对象提供了对复杂线程同步问题的支持.Condition被称为条件变量,除了提供与Lock类似的 acquire和release方法外,还提供了wait和notify ...
- 在O(1) 时间删除链表节点
struct Node { int val; Node * next; }; void deleteNode(Node ** head, Node * target) { assert(head != ...
- TranslateAnimation详解
TranslateAnimation详解 Android JDK为我们提供了4种动画效果,分别是: AlphaAnimation,RotateAnimation, ScaleAnimation, Tr ...
- BZOJ1116: [POI2008]CLO
1116: [POI2008]CLO Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 565 Solved: 303[Submit][Status] ...
- Html.DropDownList的用法
直接上代码 页面代码 <td> <%= Html.DropDownList("selCity") %> </td> controller里面的代 ...
- poj2723-Get Luffy Out
一道2-SAT问题,每对钥匙需要加一条边,每扇门上的对应的要用的钥匙加一条边. 其实求解2-SAT问题,关键在于找到不能同时成立的条件,例如在本题中,每对钥匙不能同时使用,每扇门上的钥匙不能同时不使用 ...
- USACO5.4-Character Recognition
题目大意是字符串识别一道细节很繁琐的DP,要用到很多数组一开始还真看不出是DP,后来参考了别人的代码,然后又按自己的思路重头到尾写了,虽然速度不咋的 Executing... Test 1: TEST ...
- hdu4641-K-string(后缀自动机)
Problem Description Given a string S. K-string is the sub-string of S and it appear in the S at leas ...
- LeetCode 191. Number of 1 Bits Question
题意:给你一个整数,计算该整数的二进制形式里有多少个“1”.比如6(110),就有2个“1”. 一开始我就把数字n不断右移,然后判定最右位是否为1,是就cnt++,否则就继续右移直到n为0. 可是题目 ...
- jdbc调用mysql存储过程实现代码带有输入和输出
转载自 http://www.jb51.net/article/34747.htm 1. 创建存储过程 建立一个MySQL的存储过程 add_pro 复制代码代码如下: delimiter // dr ...