Ubantu14.04下编译OpenCV3.0.0以及读取图片例子
以前一直使用opencv 2.x的版本,现在3.0的已经发布成正式版了,尝试在Linux下安装。
收集了一篇不错的经验教程:
编译的过程大概需要30分钟左右。亲测教程可用,需要注意的是把测试图片girls.jpg替换成自己的图片即可。
测试的例子
1、创建工作目录
mkdir ~/own/mycode
cd ~/own/mycode
gedit readimage.cpp
2、编辑如下代码
//! [includes]
#include <opencv2/core/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui/highgui.hpp> #include <iostream>
#include <string>
//! [includes] //! [namespace]
using namespace cv;
//! [namespace] using namespace std; int main( int argc, char** argv )
{
//! [load]
string imageName("girl.jpg"); // by default
if( argc > )
{
imageName = argv[];
}
//! [load] //! [mat]
Mat image;
//! [mat] //! [imread]
image = imread(imageName.c_str(), IMREAD_COLOR); // Read the file
//! [imread] if( image.empty() ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -;
} //! [window]
namedWindow( "Display window", WINDOW_AUTOSIZE ); // Create a window for display.
//! [window] //! [imshow]
imshow( "Display window", image ); // Show our image inside it.
//! [imshow] //! [wait]
waitKey(); // Wait for a keystroke in the window
//! [wait]
return ;
}
3、创建CMake编译文件
gedit CMakeLists.txt
写入如下内容
cmake_minimum_required(VERSION 2.8)
project( readimage )
find_package( OpenCV REQUIRED )
add_executable( readimage readimage.cpp )
target_link_libraries( readimage ${OpenCV_LIBS} )
4、编译
cd ~/own/mycode
cmake .
make
5、执行测试
可以看到目录生成了可执行文件readimage,运行:
./readimage girl.jpg
效果图如下:

嘿嘿,安装成功无误了。
参考资料
Ubantu14.04下编译OpenCV3.0.0以及读取图片例子的更多相关文章
- ubuntu16.04下安装opencv3.1.0
1.安装依赖项 sudo apt--dev pkg-config libavcodec-dev libavformat-dev libswscale-dev 可选的 sudo apt--dev lib ...
- ubuntu16.04下安装opencv-3.1.0及其扩展模块opencv_contrib
步骤1.安装依赖项 sudo apt--dev pkg-config libavcodec-dev libavformat-dev libswscale-dev 可选的 sudo apt--dev l ...
- Ubuntu16.04下安装OpenCV3.2.0
1.安装官方给的opencv依赖包 $ sudo apt-get install build-essential $ sudo apt-get install cmake git libgtk2.0- ...
- 【深度学习】ubuntu16.04下安装opencv3.4.0
1.首先安装一些编译工具 # 安装编译工具 sudo apt-get install build-essential # 安装依赖包 sudo apt-get install cmake git li ...
- Ubuntu18.04下编译安装Guitarix 0.37.3
准备工作 源文件下载 https://sourceforge.net/projects/guitarix/files/guitarix/ 安装依赖. 参考 https://sourceforge.ne ...
- Ubuntu16.04下编译安装及运行单目ORBSLAM2
官网有源代码和配置教程,地址是 https://github.com/raulmur/ORB_SLAM2 1 安装必要工具 首先,有两个工具是需要提前安装的.即cmake和Git. sudo apt- ...
- Ubuntu16.04下编译安装OpenCV3.4.0(C++ & python)
Ubuntu16.04下编译安装OpenCV3.4.0(C++ & python) 前提是已经安装了python2,python3 1)安装各种依赖库 sudo apt-get update ...
- ubuntu14.04下编译安装ambari-2.4.2.0
ubuntu14.04下编译安装ambari-2.4.2.0 编译前的准备工作 准备工作有: 系统参数 系统依赖(编译环境) 离线安装包 java环境 maven环境 Nodejs环境 git环境 a ...
- Ubuntu16.04+cuda8.0rc+opencv3.1.0+caffe+Theano+torch7搭建教程
https://blog.csdn.net/jywowaa/article/details/52263711 学习中用到深度学习的框架,需要搭建caffe.theano和torch框架.经过一个月的不 ...
随机推荐
- 安装ssh-keygen
转载自:http://www.daoan.com/forums/index.php?forumid=5&mods=topicdisplay&postid=4 sudo apt-get ...
- Machine Learning系列--维特比算法
维特比算法(Viterbi algorithm)是在一个用途非常广的算法,本科学通信的时候已经听过这个算法,最近在看 HMM(Hidden Markov model) 的时候也看到了这个算法.于是决定 ...
- Tutorial 3: Class-based Views
转载自:http://www.django-rest-framework.org/tutorial/3-class-based-views/ Tutorial 3: Class-based Views ...
- Tutorial 1: Serialization
转载自:http://www.django-rest-framework.org/tutorial/1-serialization/#tutorial-1-serialization Tutorial ...
- Sklearn-GridSearchCV网格搜索
GridSearchCV,它存在的意义就是自动调参,只要把参数输进去,就能给出最优化的结果和参数.但是这个方法适合于小数据集,一旦数据的量级上去了,很难得出结果.这个时候就是需要动脑筋了.数据量比较大 ...
- ansible command模块将返回值写入变量
ansible 中command模块支持 register参数将远程命令执行的输出结果存储在变量中,后续可以在when中对该变量进行检索确定下一步任务. --- - name: cat /etc/re ...
- Oracle常用sql语句(二)之组函数、多表查询
DML(数据操纵语言) INSERT .UPDATE. DELETE 插入操作:INSERT: 语法: INSERT INTO 表名(列名1,列名2 ...)VALUES(列值1,列值2...); 注 ...
- Mysql授权允许远程访问
MySQL Community Edition(GPL) 在我们使用mysql数据库时,有时我们的程序与数据库不在同一机器上,这时我们需要远程访问数据库.缺省状态下,mysql的用户是没有远程访问的权 ...
- python基础(12)--初识Socket
socket: 网络上的两个程序通过一个双向的通信连接实现数据的交换,这个连接的一端称为一个socket. Socket的英文原义是“孔”或“插座”.作为BSD UNIX的进程通信机制,取后一种意思. ...
- IEEEXtreme 10.0 - Playing 20 Questions with an Unreliable Friend
这是 meelo 原创的 IEEEXtreme极限编程大赛题解 Xtreme 10.0 - Playing 20 Questions with an Unreliable Friend 题目来源 第1 ...