*Update: For OpenCV 2.4 on Ubuntu 12.04 see my latest post.
This post will guide you on how to compile and run OpenCV 2.3.1 on Ubuntu 10.10 or later.
First, install all prerequisites:
Download OpenCV:
This post will guide you on how to compile and run OpenCV 2.3.1 on Ubuntu 10.10 or later.
First, install all prerequisites:
sudo apt-get install build-essential checkinstall git cmake ffmpeg 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 libtbb-dev libv4l-dev libopenexr-dev libunicap2-dev libavformat-dev libswscale-dev libdc1394-22-dev 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 python-numpyThis is not a minimal set of libraries, but it's a collection that will give you most of the functionality. For example, if you are sure that you will never need to use a firewire camera, you can ignore libdc1394-22-dev. But if you actually need to use this feature you will have to recompile OpenCV. Also, if you need CUDA support, follow the instructions in this post before continuing here.
Download OpenCV:
wget downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.3.1/OpenCV-2.3.1a.tar.bz2Extract and create a build directory:
tar -xvf OpenCV-2.3.1a.tar.bz2 cd OpenCV-2.3.1/ mkdir build cd buildNow run cmake:
cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=OFF -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON ..At this point check the output of cmake to make sure that all the features you are going to need are supported. If not you will have to install the corresponding libraries and run cmake again. Compile:
makeIf everything went well you can go ahead and install:
sudo make installFinally, add the following lines in your .bashrc:
# OpenCV stuff PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfigTo test that everything works, let's run the face detection demo. Go to the bin directory:
cd binAnd run:
./facedetect --cascade="../../data/haarcascades/haarcascade_frontalface_alt.xml" --nested-cascade="../../data/haarcascades/haarcascade_eye.xml" --scale=1.3 ../../samples/c/lena.jpgYou should see something like this: