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= ...
随机推荐
- JDBC开发模式
一]代码模块———Demo.java public class Demo { private static Connection connection; private static Statemen ...
- MFC消息映射与命令传递
题外话:刚开始学视窗程序设计的时候,我就打印了一本Windows消息详解,里面列举了各种已定义消息的意义和作用,共10多页,在编程的时候翻翻,有时觉得很受用.我发觉很多编程的朋友,虽然每天都面对消息, ...
- 奇葩的SQL*Net more data from client等待,导致批处理巨慢
<pre name="code" class="sql"><pre name="code" class="sql ...
- 开机启动tomcat
windows: 成功之后在dos窗口键入 service.bat install Tomcat 输完然后按Enter键,出现如下窗口,便成功了. 进入windows服务管理,设成是自动的. #chk ...
- mysql常用查询归纳
一.mysql查询的五种子句 where(条件查询).having(筛选).group by(分组).order by(排序).limit(限制结果数) .where常用运算符: 比较运算符 > ...
- libeXosip2(3) -- SIP messages and call control API
SIP messages and call control API The SIP messages and call control API. More... Modules eXosip2 INV ...
- poj 3273 Monthly Expense(二分搜索之最大化最小值)
Description Farmer John ≤ moneyi ≤ ,) that he will need to spend each day over the next N ( ≤ N ≤ ,) ...
- java DI 框架spring(web)、Guice(web)、Dagger&Dagger2(android)
java DI 框架spring(web).Guice(web).Dagger&Dagger2(android) (待续...)
- 小米路由器mini建FTP
输入命令 df -h 复制代码 查看自己的分区路径,我自己用了一个闲置笔记本电脑硬盘转USB,插到mini,有四个区 为了方便,我选择把ftp安装在第一个分区 /extdisks/sda1/ 创建f ...
- Android开发之DatePickerDialog与TimePickerDialog的功能和使用方法具体解释
DatePickerDialog与TimePickerDialog的功能比較简单,使用方法也非常easy.仅仅要以下两步就可以. Ø 通过newkeyword创建DatePickerDialog.T ...