ubuntu14.04安装opencv2.4.9

1.设置安装目录:

cd 你想要安装的地方

mkdir opencv(若使用sudo mkdir opencv,则用户就没修改的权限了)

sudo apt-get update

2.卸载任何以前安装的ffmpeg和x264软件。Ffmpeg是一套可以用来记录、转换数字音频、视频,并能将其转化为流的开源计算机程序。(注:不进行这一步不知道可不可以??)

sudo apt-get -qq remove ffmpegx264 libx264-dev

ps:有的网站上没有进行这一步,不知道行不?(我对这一步进行了操作)


3.安装一些依赖文件

sudo apt-get installlibopencv-dev build-essential checkinstall cmake pkg-config yasmlibjpeg-dev libjasper-dev libavcodec-dev libavformat-devlibswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-devlibgstreamer-plugins-base0.10-dev libv4l-dev python-devpython-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-devlibmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-devlibtheora-dev libvorbis-dev libxvidcore-dev x264v4l-utils


4.安装ffmpeg

sudo add-apt-repositoryppa:mc3man/trusty-media

sudo apt-get update

sudo apt-get install ffmpeggstreamer0.10-ffmpeg

ps:我的出现了问题,但对后面安装opencv没有影响


5.下载和解压提取OpenCV

sudo wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.9/opencv-2.4.9.zip
unzip opencv-2.4.9.zip
cd opencv-2.4.9

6.开始编译安装

mkdir build

cd build

 
  
cmake -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 -D WITH_VTK=ON ..

make -j2 或make (-j2可以提高make的效率)


sudo make install

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

sudo ldconfig

7.然后重启电脑


8.运行opencv例子


cd /usr/local/share/OpenCV/samples/c
sudo chmod +x build_all.sh

sudo ./build_all.sh

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

参考网站:http://blog.sina.com.cn/s/blog_7b83134b0102wabk.html

http://sysads.co.uk/2014/05/install-opencv-2-4-9-ubuntu-14-04-13-10/


你可能感兴趣的:(ubuntu14.04安装opencv2.4.9)