Ubuntu14.04安装OpenCV

前端之家收集整理的这篇文章主要介绍了Ubuntu14.04安装OpenCV前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1 开发环境

Ubuntu14.04(64bit)

OpenCV-3.1.0

cmake-

gcc-4.8.4

g++-4.8.4

2 安装cmake

sudo apt-get install cmake

3 下载&编译

1)下载opencv-3.1.0.zip

2) 解压opencv-3.10.zip

unzip opencv-3.1.0.zip

3)进入解压生成opencv-3.1.0目录:

cd opencv-3.1.0

4)创建并且进入编译目录build

mkdir build
cd build
5)cmake配置:

DEBUG版:

cmake -D CMAKE_BUILD_TYPE=DEBUG -D CMAKE_INSTALL_PREFIX=/usr/local ..

RELEASE版:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
6)编译:
make

7)安装:

sudo make install

4 测试

4.1 DisplayImage.cpp

#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc,char** argv )
{
	if ( argc != 2 )
	{
		printf("usage: DisplayImage.out <Image_Path>\n");
		return -1;
	}
	Mat image;
	image = imread( argv[1],1 );
	if ( !image.data )
	{
		printf("No image data \n");
		return -1;
	}
	namedWindow("Display Image",WINDOW_AUTOSIZE );
	imshow("Display Image",image);
	waitKey(0);
	return 0;
}
4.2CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV required )
add_executable( DisplayImage DisplayImage.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )
4.3 配置&编译
cmake .
make
4.4 测试
DisplayImage test.png

参考资料

[1]ubuntu14.04+opencv 3.0安装及测试

原文链接:https://www.f2er.com/ubuntu/356283.html

猜你在找的Ubuntu相关文章