ubuntu12.04安装OpenCV2.4。1
2012-06-26 14:41
295 查看
The Installation Procedure
To install and configure OpenCV 2.4.1, complete the following steps. The commands shown in each step can be copy and pasted directly into a Linux command line.Remove any installed versions of ffmpeg and x264.
sudo apt-get remove ffmpeg x264 libx264-dev
Get all the dependencies for x264 and ffmpeg.
sudo apt-get update sudo apt-get install build-essential checkinstall git cmake libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev texi2html yasm zlib1g-dev
Download and install gstreamer.
sudo apt-get install libgstreamer0.10-0 libgstreamer0.10-dev gstreamer0.10-tools gstreamer0.10-plugins-base libgstreamer-plugins-base0.10-dev gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly gstreamer0.10-plugins-bad gstreamer0.10-ffmpeg
Download and install gtk.
sudo apt-get install libgtk2.0-0 libgtk2.0-dev
Download and install libjpeg.
sudo apt-get install libjpeg8 libjpeg8-dev
Create a directory to hold source code.
cd ~ mkdir src
Download and install install x264.
Download a recent stable snapshot of x264 from ftp://ftp.videolan.org/pub/videolan/x264/snapshots/. The exact version does not seem to matter. To write this guide, I used version x264-snapshot-20120528-2245-stable.tar.bz2, but I have used previous versions too.
cd ~/src
wget ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20120528-2245-stable.tar.bz2
tar xvf x264-snapshot-20120528-2245-stable.tar.bz2
cd x264-snapshot-20120528-2245-stable
Configure and build the x264 libraries.
./configure --enable-static make sudo make install
IMPORTANT: If you are running a 64-bit version of Ubuntu, you must configure x264 as shown in the following command:
./configure --enable-shared --enable-pic
The -shared and -pic options might also be required when you compile for some other architectures, such as ARM. You know you need these options if you get the following error when compiling OpenCV:
[ 25%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/bitstrm.cpp.o Linking CXX shared library ../../lib/libopencv_highgui.so /usr/bin/ld: /usr/local/lib/libavcodec.a(avpacket.o): relocation R_X86_64_32S against `av_destruct_packet' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libavcodec.a: could not read symbols: Bad value
Download and install install ffmpeg.
Download ffmpeg version 0.11.x from http://ffmpeg.org/download.html.
cd ~/src wget http://ffmpeg.org/releases/ffmpeg-0.11.tar.bz2 tar xvf ffmpeg-0.11.tar.bz2 cd ffmpeg-0.11
Configure and build ffmpeg. //如果是ubuntu是安装在虚拟机上,需要加上
--enable-shared
./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab
make sudo make install
IMPORTANT: Just like with x264 in the previous step, you must configure ffmpeg with the -shared option if you are running a 64-bit version of Ubuntu or some other architectures, such as ARM. The -pic option is not necessary for ffmpeg.
./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab --enable-shared
Download and install install a recent version of v4l (video for linux) from http://www.linuxtv.org/downloads/v4l-utils/. For this guide I used version 0.8.8.
cd ~/src
wget http://www.linuxtv.org/downloads/v4l-utils/v4l-utils-0.8.8.tar.bz2
tar xvf v4l-utils-0.8.8.tar.bz2
cd v4l-utils-0.8.8
make sudo make install
Download and install install OpenCV 2.4.1.
Download OpenCV version 2.4.1 from http://sourceforge.net/projects/opencvlibrary/files/
cd ~/src
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.1/OpenCV-2.4.1.tar.bz2
tar xvf OpenCV-2.4.1.tar.bz2
Create a new build directory and run cmake:
cd OpenCV-2.4.1/ mkdir build cd build cmake -D CMAKE_BUILD_TYPE=RELEASE ..
Verify that the output of cmake includes the following text:
found gstreamer-base-0.10
GTK+ 2.x: YES
FFMPEG: YES
GStreamer: YES
V4L/V4L2: Using libv4l
Build and install OpenCV.
make sudo make install
Configure Linux.
Tell linux where the shared libraries for OpenCV are located by entering the following shell command:
export LD_LIBRARY_PATH=/usr/local/lib
Add the command to your .bashrc file so that you don’t have to enter every time your start a new terminal.
Alternatively, you can configure the system wide library search path. Using your favorite editor, add a single line containing the text
/usr/local/libto the end of a file named
/etc/ld.so.conf.d/opencv.conf. In the standard Ubuntu install, the opencv.conf file does not exist; you need to create it. Using vi, for example, enter the following commands:
sudo vi /etc/ld.so.conf.d/opencv.conf G o /usr/local/lib <Esc> :wq!
After editing the opencv.conf file, enter the following command:
sudo ldconfig /etc/ld.so.conf
.
Using your favorite editor,
4000
add the following two lines to the end of /etc/bash.bashrc:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH
8 运行例程测试
1 cd ~
4 cd openCV_samples/c
5 chmod +x build_all.sh
6 ./build_all.sh
7
8 ./facedetect --cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml" --scale=1.5 lena.jpg
More Information
If you encounter problems installing OpenCV, see the companion guide, “A Comprehensive OpenCV Installation Troubleshooting Guide.”Utkarsh Sinha runs AiShack, a site that has easy-to-understand tutorials using OpenCV to solve real-world problems:
http://www.aishack.in/topics/tutorials/
Sebastian Montabone has several articles on installing OpenCV and image processing. His web site is
http://www.samontab.com/
FakeOutdoorsman’s posted an excellent dependency install guide, which is located on the Ubuntu forums:
http://ubuntuforums.org/showthread.php?t=786095
相关文章推荐
- ubuntu12.04上安装PCL+opencv2.4
- ubuntu12.04安装opencv-1.0.0的问题(希望大家进来讨论一下)
- 学习opencv(1)--VS2008下安装opencv2.4 配置 显示图像
- zedboard--ubuntu12.04下Opencv2.3.1安装过程(对十七的补充)
- VS2010环境下安装并配置OpenCV2.4
- ubuntu12.04 下 Python开发环境搭建以及matplotlib库和openCV的安装
- ubuntu12.04安装openCV2.4.2
- Qt中用OpenCV2.4读取并把图像显示在QLabel中 (Ubuntu12.04)
- 在Ubuntu14.04.5上安装OpenCV2.4.9时遇到的各种问题
- Python学习之一:Python2.7与opencv2.4安装配置
- opencv在ubuntu12.04下的安装
- ubuntu12.04 安装opencv 并解决undefined reference to `cvLoadImage’的问题
- Ubuntu12.04安装OpenCV 2.4.1
- Ubuntu12.04安装openCV
- linux下安装OpenCV-2.4
- ubuntu12.04安装opencv-1.0.0的问题(希望大家进来讨论一下) (转载增补)
- Ubuntu 16.04 安装opencv2.4
- Opencv2.4和Opencv3.1安装总结
- ubuntu12.04安装opencv-2.4.9
- ubuntu12.04安装openCV2.4.2