A quick guide to installing OpenCV 2.4.0 with cvBlob on Ubuntu 12.04.
I have recently had to do multiple installs of OpenCV on a few systems and noticed that there wasn't one site that suited my needs for a quick install for everything I needed. I decided to fully document my steps and put this up here for future reference.
Installing OpenCV
This guide was written and compiled with the help from the following pages:
https://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide
http://thebitbangtheory.wordpress.com/2011/10/23/how-to-install-opencv-2-3-1-in-ubuntu-11-10-oneiric-ocelot-with-python-support/
So, let's get started...
Remove any existing packages:
sudo apt-get remove ffmpeg x264 libvpx-dev libx264-dev
sudo apt-get update
Install base dependencies:
sudo apt-get install build-essential checkinstall git pkg-config cmake libpng12-0 libpng12-dev libpng++-dev libpng3 libpnglite-dev libfaac-dev libjack-jackd2-dev libjasper-dev libjasper-runtime libjasper1 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 zlib1g-dbg zlib1g libgstreamer0.10-0 libgstreamer0.10-dev libgstreamer0.10-0-dbg 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 pngtools libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-progs libavcodec-dev libavcodec53 libavformat53 libavformat-dev libxine1-ffmpeg libxine-dev libxine1-bin libunicap2 libunicap2-dev libdc1394-22-dev libdc1394-22 libdc1394-utils swig python-numpy  libpython2.7 python-dev python2.7-dev libjpeg-progs libjpeg-dev libgtk2.0-0 libgtk2.0-dev gtk2-engines-pixbuf
-->x264
H.264 video encoder. The following commands will get the current source files, compile, and install x264.
cd
git clone git://git.videolan.org/x264
cd x264
./configure --enable-static
Note: I ran into trouble and had due to x64 error so I had to change configure line to add --enable-pic and --enable-shared.
./configure --enable-static --enable-pic --enable-shared
make
sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | \
 awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes \
 --fstrans=no --default
-->libvpx
VP8 video encoder and decoder.
cd
git clone http://git.chromium.org/webm/libvpx.git
cd libvpx
./configure
make
sudo checkinstall --pkgname=libvpx --pkgversion="1:$(date +%Y%m%d%H%M)-git" --backup=no --deldoc=yes --fstrans=no --default
-->ffmpeg
cd
git clone --depth 1 git://source.ffmpeg.org/ffmpeg
cd ffmpeg
./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-version3 --enable-x11grab
Note: I ran into trouble and had due to x64 error so I had to change configure line to add --enable-pic and --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 --enable-pic --enable-shared
make
sudo checkinstall --pkgname=ffmpeg --pkgversion="5:$(date +%Y%m%d%H%M)-git" --backup=no --deldoc=yes --fstrans=no --default
hash x264 ffmpeg ffplay ffprobe
-->v4l
Download and install v4l – download any recent stable snapshot from http://www.linuxtv.org/downloads/v4l-utils/ (I used v4l-utils-0.8.5.tar.bz2) and extract it to a folder. Then enter the folder and build it:
make
sudo make install
-->OpenCV
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ..
make
sudo make install
-->Add OpenCV libs to system path
vim ~/.bashrc
export LD_LIBRARY_PATH=/usr/local/lib
sudo vim /etc/bash.bashrc
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
-->Check python install
python
import cv2
-->Compile all samples
chmod +x build_all.sh
./build_all.sh
-->To compile using pkg-config
g++ `pkg-config --cflags opencv` my_code.cpp -o my_code `pkg-config --libs opencv`
-->cvBlob
Grab the latest version from: http://code.google.com/p/cvblob/downloads/list
At the time of writing the current version is here: http://cvblob.googlecode.com/files/cvblob-0.10.3-src.tgz
cmake . -DOpenCV_DIR=<path_to_OpenCV>
Note:cmake . -DOpenCV_DIR=/usr/local/include/opencv
make
sudo make install
Output should be:
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/lib/pkgconfig/cvblob.pc
-- Installing: /usr/local/include/cvblob.h
-- Installing: /usr/local/lib/libcvblob.so
For the dependencies I needed to compile from source (x264, libvpx, ffmpeg and v4l) I created a folder named dependencies in the main OpenCV 2.4.0 folder to keep everything together. Apart from that everything was done as stated above. The main thing to remember if you are using an x64 architecture is adding the: "--enable-pic and --enable-shared" when you are compiling x264 and ffmpeg. Â











