Install OpenCV 2.4.* in Ubuntu 12.04 Precise Pangolin


Install OpenCV 2.4.0

Install OpenCV 2.4.1

Install OpenCV 2.4.2

Install OpenCV 2.4.3

Install OpenCV 2.4.4

Install OpenCV 2.4.5

Remove any installed versions of ffmpeg and x264.

sudo apt-get remove remove ffmpeg x264 libx264-dev

Install all the dependencies.

sudo apt-get install libopencv-dev
sudo apt-get install build-essential checkinstall cmake pkg-config yasm
sudo apt-get install libtiff4-dev libjpeg-dev libjasper-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev
sudo apt-get install python-dev python-numpy
sudo apt-get install libtbb-dev
sudo apt-get install libqt4-dev libgtk2.0-dev

Download the latest version ox x264 from x264 snapshots

tar -xvf x264-snapshot-version.tar.bz2
cd x264-snapshot-version/

If you are using 32 bit Linux

./configure --enable-static

If you’re using 64 bit Linux

./configure --enable-shared --enable-pic

Install it

make
sudo make install

Download the latest version of ffmpeg from ffmpeg Download.

tar -xvf ffmpeg-version.tar.bz2
cd ffmpeg-version/

If you’re using 32 bit Linux

./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

If you’re using 64 bit Linux or ARM

./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**

Install it

make
sudo make install

Download the latest image of v4l from v4l-utils

tar -xvf v4l-version.tar.bz2
cd v4l-version
make
sudo make install

Download OpenCV 2.4.0

Download OpenCV 2.4.1

Download OpenCV 2.4.2

Download OpenCV 2.4.3

Download OpenCV 2.4.4

Download OpenCV 2.4.5

After downloading OpenCV 2.4.* package, untar it and make.

tar -xvf OpenCV-version.tar.bz2
cd OpenCV-version/
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

OpenCV 2.4.* is now installed. Just make sure that all the libraries are linked properly. Go to samples directory in OpenCV package. Change directory to C or C++. You’ll find a script there named build_all.sh. Execute the script. It will make all the files. select any output file and run it. If it works then you are good to go.

sudo echo "/usr/local/lib" >> /etc/ld.so.conf
sudo ldconfig

Your OpenCV 2.4.* is installed and libraries are properly linked. If you don’t have much experience with OpenCV, I would suggest you to go through this post. Beginning OpenCV. It shows how to make a script so that you don’t need to add everything while compiling opencv codes.

P.S. My Python port of George Nebehay’s OpenTLD Version is almost ready.

Get data from Mat / cv::Mat in OpenCV

Read next