文档章节

Install OpenCV 2.4.9 in Ubuntu 14.04, 13.10

wangxuwei
 wangxuwei
发布于 2016/07/11 21:33
字数 796
阅读 73
收藏 0



OpenCV is the most popular and advanced code library for Computer Vision related applications today, spanning from many very basic tasks (capture and pre-processing of image data) to high-level algorithms (feature extraction, motion tracking, machine learning). It is free software and provides a rich API in C, C++, Java and Python. Other wrappers are available. The library itself is platform-independent and often used for real-time image processing and computer vision.

What’s new in 2.4.9

  • new 3D visualization module ‘viz’
  • performance fixes in ‘ocl’ module
  • fixes in Android Camera
  • improved CUDA support for mobile platforms
  • bugfixes from community
  • 55 reported bugs have been closed
  • 156 pull requests have been merged

See the full ChangeLog for more information

Install OpenCV

Step 1: Make Directory

mkdir opencv

cd /opencv/

Step 2: Remove any pre-installed ffmpeg and x264

sudo apt-get -qq remove ffmpeg x264 libx264-dev

Step 3:  Install Dependenices

 

As reported by kumaranbus, installing ‘libopencv-dev‘ on non nvidia graphics card messes up the drivers. As a workaround for non nvidia cards like AMD/ATI, Radeon, replace libopencv-dev below with ‘ocl-icd-libopencl1‘ which is a generic driver. Please note that I have not tried this out yet as I have no ATI/Radeon cards to test with

 

sudo apt-get -qq install libopencv-dev build-essential checkinstall cmake pkg-config yasm libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils

- Install ffmpeg

sudo add-apt-repository ppa:mc3man/trusty-media

sudo apt-get update

sudo apt-get install ffmpeg gstreamer0.10-ffmpeg

Step 4: Download and extract OpenCV

wget -O OpenCV-2.4.9.zip http://fossies.org/linux/misc/opencv-2.4.9.zip

unzip OpenCV-2.4.9.zip

cd opencv-2.4.9

Step 5: Begin Build Process

Note that this bit would take some time to complete

mkdir build

cd build

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..

make -j2

sudo make install

sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'

sudo ldconfig

opencv-2.4.9-01

- Reboot your machine

Step 6: Example using OpenCV

- Change directory to following location

cd /usr/local/share/OpenCV/samples/c

- Execute following commands

sudo chmod +x build_all.sh

sudo ./build_all.sh

./facedetect "/usr/share/opencv/haarcascades/haarcascade_frontalface_alt.xml" lena.jpg

or

./facedetect --cascade="/usr/share/opencv/haarcascades/haarcascade_frontalface_alt.xml" lena.jpg

opencv-2.4.9-02

2.4.13以及3.2.0

cmake  -D CMAKE_BUILD_TYPE=Releases WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D OPENCV_BUILD_3RDPARTY_LIBS=ON WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON  -D WITH_QT=ON -D CMAKE_INSTALL_PREFIX=/opt/local/opencv2.4.13 ..

cmake  -D CMAKE_BUILD_TYPE=Releases -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON OPENCV_BUILD_3RDPARTY_LIBS=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON  -D WITH_QT=ON -D CMAKE_INSTALL_PREFIX=/opt/local/opencv3.2.0 ..

编译过程中出现下载ippicv_linux_20151201.tgz失败的解决:

 cd opencv-3.2.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/
wget https://raw.githubusercontent.com/Itseez/opencv_3rdparty/81a676001ca8075ada498583e4166079e5744668/ippicv/ippicv_linux_20151201.tgz

环境变量:

#opencv environment
#export OPENCV=/opt/local/opencv2.4.13 
export OPENCV=/opt/local/opencv3.2.0
export PATH=$PATH:$OPEVCV/bin  
export LD_LIBRARY_PATH=$OPENCV/lib:$LD_LIBRARY_PATH 
export PKG_CONFIG_PATH=$OPENCV/lib/pkgconfig:$PKG_CONFIG_PATH

多版本(默认3.2下使用2.4):

sudo cp /opt/local/opencv2.4.13/lib/pkgconfig/opencv.pc /opt/local/opencv3.2.0/lib/pkgconfig/opencv2.4.pc 

vi /opt/local/opencv3.2.0/lib/pkgconfig/opencv2.4.pc

在libs:最后面追加 -Wl,-rpath=/opt/local/opencv2.4.13/lib

修改后的opencv2.4.pc内容如下:

# Package Information for pkg-config

prefix=/opt/local/opencv2.4.13
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir_old=${prefix}/include/opencv
includedir_new=${prefix}/include

Name: OpenCV
Description: Open Source Computer Vision Library
Version: 2.4.13
Libs: -L${exec_prefix}/lib -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_ocl -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab -L/usr/lib/x86_64-linux-gnu -lGL -lGLU -lrt -lpthread -lm -ldl -Wl,-rpath=/opt/local/opencv2.4.13/lib
Cflags: -I${includedir_old} -I${includedir_new}

使用:g++ first.cpp -o first `pkg-config --cflags --libs opencv2.4`

// g++ first.cpp -o first `pkg-config --cflags --libs opencv2.4`
//显示图像文件
#include <opencv2/opencv.hpp>
using namespace std;

int main()
{
	const char *pstrImageName = "冲浪大师赛001.jpg";
	const char *pstrWindowsTitle = "OpenCV第一个程序(http://blog.csdn.net/MoreWindows)";

	//从文件中读取图像
	IplImage *pImage = cvLoadImage(pstrImageName, CV_LOAD_IMAGE_UNCHANGED);

	//创建窗口
	cvNamedWindow(pstrWindowsTitle, CV_WINDOW_AUTOSIZE);

	//在指定窗口中显示图像
	cvShowImage(pstrWindowsTitle, pImage);

	//等待按键事件
	cvWaitKey();

	cvDestroyWindow(pstrWindowsTitle);
	cvReleaseImage(&pImage);
	return 0;
}

该程序在2.4.13下正常运行

本文转载自:http://blog.csdn.net/xiaojidan2011/article/details/40153933

wangxuwei
粉丝 26
博文 336
码字总数 119651
作品 0
杭州
其他
私信 提问
加载中

评论(1)

6组源声
6组源声
[强]
opencv-3.0.0在Ubuntu14.04下的配置与安装

original url: http://blog.csdn.net/surgewong/article/details/39078251 每次学习新东西或者换新的电脑,最让人头疼的就是环境的安装了。网上有一大堆教程,不过总地来讲,比较混乱,有些甚...

junmuzi
2015/11/17
0
0
ubuntu14.04中安装opencv2.4.9

先从sourceforge上下载OpenCV的源码 http://jaist.dl.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.9/opencv-2.4.9.zip 2. 解压到任意目录 unzip opencv-2.4.9.zip 3. 进入源码目......

xwisen
2014/07/23
0
0
python opencv linux下合作操作摄像头

设想: 之前使用C#控制摄像头的,现在厌烦了windows,决定转移到linux下玩耍。感觉能够python语言特有的好入手,正好替代C#,选择了deepin2014.1作为试验品。现在的设想是第一步实现在自己电...

不避风云
2014/09/13
0
28
执行脚本./build.sh时出错

@刘若则 你好,想跟你请教个问题: 这个车牌识别系统支持的Opencv版本必需是opencv3.1.0么? 我执行./build.sh这个脚本的时候会出现下面的错误 CMake Error at CMakeLists.txt:19 (find_packa...

阿呆问
2016/06/10
582
0
centos操作系统 ,opencv, java调用编译后的opencv动态链接库报错

各位大牛好: 遇到一个棘手问题需要请教各位有opencv经验开发的大牛。 在centos6.5/opencv2.4.9/jdk1.7/cmake3.0环境下,编译opencv 并支持java模块,编译成功后,通过opencv编译后的build 生...

yanfengben
2014/10/24
2.1K
2

没有更多内容

加载失败,请刷新页面

加载更多

我为什么要写微信公众号

埋一颗种子,细心呵护,静待她枝繁叶茂,葱郁参天 V2论坛上有个帖子【做程序员最重要的还是一定要有自己的作品】,作者写道: 能有一个作品和你的名字联系在一起,应当成为在职业生涯前期着意...

运维咖啡吧
23分钟前
2
0
数据库

数据库架构 数据库架构可以分为存储文件系统和程序实例两大块,而程序实例根据不同的功能又可以分为如下小模块。 1550644570798 索引模块 常见的问题有: 为什么要使用索引 什么样的信息能成...

一只小青蛙
今天
5
0
PHP常用经典算法实现

<? //-------------------- // 基本数据结构算法 //-------------------- //二分查找(数组里查找某个元素) function bin_sch($array, $low, $high, $k){ if ( $low <= $high){ $mid = int......

半缘修道半缘君丶
昨天
5
0
GIL 已经被杀死了么?

本文原创并首发于公众号【Python猫】,未经授权,请勿转载。 原文地址:https://mp.weixin.qq.com/s/8KvQemz0SWq2hw-2aBPv2Q 花下猫语: Python 中最广为人诟病的一点,大概就是它的 GIL 了。...

豌豆花下猫
昨天
6
0
git commit message form

commit message一般包括3部分:Header、Body、Footer。 <type>(<scope>):<subject>blank line<body>blank line<footer> header是必需的,body、footer可以省略。 header中type、subject......

ninjaFrog
昨天
5
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部