Thursday, February 27, 2014

how to install opencv on linux

below find the steps to install opencv on linux (particularly ubuntu)

1. Remove any installed versions of ffmpeg and x264.
sudo apt-get remove ffmpeg x264 libx264-dev

2. update
sudo apt-get update

3. Get all the dependencies for x264 and ffmpeg. If you have them, it will skip it anyways.
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

4. Download and install gstreamer. ( gstreamaer and ffmpeg and x264 are important for video processing)
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

5. Download and install gtk. If you have it, it will be skipped anyways.
sudo apt-get install libgtk2.0-0 libgtk2.0-dev

6. Download and install libjpeg. If you have it, it will be skipped anyways.
sudo apt-get install libjpeg8 libjpeg8-dev

7. Download and install install x264. ( check if there is any previous version available)
cd ~
mkdir ffmpeg_sources
cd ~/ffmpeg_sources
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 --enable-shared --enable-pic (FOR 64-BIT MACHINE, OTHERWISE REMOVE --enable-pic)
make
sudo make install

8. Download and install install ffmpeg. ( check if there is any previous version available)
cd ~/ffmpeg_sources
wget http://ffmpeg.org/releases/ffmpeg-0.11.1.tar.bz2
tar xvf ffmpeg-0.11.1.tar.bz2
cd ffmpeg-0.11.1
./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 --enable-pic (FOR 64-BIT MACHINE, OTHERWISE REMOVE --enable-pic)
make sudo make install

9. Download and install install a recent version of v4l ( check if there is any previous version available)
cd ~/ffmpeg_sources
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

10. Download and install OpenCv (check if there is any previous version available)
cd ~
mkdir opencv
cd opencv
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.8/OpenCV-2.4.8.tar.bz2
tar xvf OpenCV-2.4.8.tar.bz2
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local .. (CHECK THE FINAL CMAKE OUTPUT FOR gstreamer, ffmpeg, v4l, and gtk)
make
sudo make install
sudo ldconfig

information is gathered from this and there as well as additional tweaks
http://www.ozbotz.org/opencv-installation/
http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html
http://indranilsinharoy.com/2012/11/01/installing-opencv-on-linux/

No comments:

Post a Comment