Ubuntu14.04安装OpenCV3

1、首先使用下列命令安装OpenCV需要的依赖:

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

2、下载OpenCV3

mkdir opencv
cd opencv
wget https://github.com/Itseez/opencv/archive/3.0.0-alpha.zip -O opencv-3.0.0-alpha.zip
unzip opencv-3.0.0-alpha.zip

3、安装OpenCV

cd opencv-3.0.0-alpha
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 ..
make -j $(nproc)
sudo make install


4、完成安装

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

这里建议重启系统;



Lets test it!

We will test to check if everything is working properly. Doesn’t matter if I say you should do this way if it doesn’t work, right? Come on! I’m assuming you just restart your computer after you have performed the above steps or the given script.

1st test: Running an OpenCV sample

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

If everything went right, you’ll see Lenna. Press ENTER to close.

下载地址:https://download.csdn.net/download/cyf15238622067/10315684
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Dwyane05

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值