Linux学习 - Ubuntu 14.04配置Opencv环境

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/chenfs1992/article/details/50017379

准备工作

确保自己的apt-get是正常的,能够安装软件。

  1. 安装必须的依赖
sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen3-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev default-jdk ant libvtk5-qt4-dev

运行以上命令,这个是所有需要的软件。
2. 下载源码包

wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/3.0.0/opencv-3.0.0.zip?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fopencvlibrary%2F&ts=1448329023&use_mirror=jaist

下载完之后,解压:

unzip opencv3.0.0.zip //包名字

编译

然后进入到文件夹里,并进行如下操作:

cd opencv-3.0.0

mkdir build

cd build

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

等待编译成功,中间可能有个download一个依赖比较慢~ 等懿德就好。

安装

然后就可以:

make

make install

安装玩之后执行如下命令:(为了告诉ubuntu opencv的存在)

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

sudo ldconfig

这样就成功了。

测试

First of all, we need to compile the samples. Worth saying that the commands below can be avoided by adding the options to build samples on the 3rd step of installation.

cd opencv/opencv-3.0.0-alpha/samples/
sudo cmake .
sudo make -j $(nproc)
Now you can run a sample. I chose two, but feel free to run any other. The goal here is to prove that our OpenCV installation was a success. The samples we’re going to run are the FaceDetect and HoughtLines developed in C++.

cd cpp/
./cpp-example-facedetect lena.jpg // (../data/lena.jpg) OpenCV 3.0 beta
./cpp-example-houghlines pic1.png // (../data/pic1.jpg) OpenCV 3.0 beta
Note 1: If you’re using OpenCV 3.0 beta, both images are inside “../data/” directory;
Note 2: To close the window with Lenna, just press ENTER. The same to finish HoughLines. Go on and run other samples;

2nd test:  Running our own program

What about compiling something we made? Just below I am providing a simple program whose purpose is to display an image. Unzip it and run the commands below inside the folder you just created.

sudo cmake .
sudo make
./DisplayImage lena.jpg

一键安装脚本

在以下链接里:(https://github.com/chenfushan/library-for-alps/blob/master/shell/install-opencv.sh)
直接运行即可。

阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页