Following are the instructions to install OpenCV on Ubuntu machine. I am using latest version of OpenCV 2.4.8 and latest version of Ubuntu 13.10. For old versions (2.3 and earlier) of OpenCV you can follow my earlier blog post here. Installing new version of OpenCV is slightly different hence I am presenting this post.
sudo apt-get install libgtk2.0-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.8/
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D MAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
make
Now your machine is ready to rock with OpenCV.
Following steps will guide you to install OpenCV 2.4.8 on Ubuntu 13.10
1. First we will install essential tools for buidling OpenCV. Use following command in your terminal to install them.
sudo apt-get install build-essential cmake pkg-config2. Following command will install required Image I/O libraries.
sudo apt-get install libjpeg62-dev libtiff4-dev libjasper-dev3. Install gtk libraries for highgui
4. Install required video libraries.
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
5. Download OpenCV from sourceforge using below link and extract zipped file. Enter into zipped directly.
http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.8/
6. Create a build directory in zipped file and enter into it using following terminal command.
mkdir build
cd build
7. Type following command in terminal window to start building process.
cmake -D CMAKE_BUILD_TYPE=RELEASE -D MAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
8. Compile the source code using following command.
make
9. Install OpenCV using following command.
sudo make installNow your machine is ready to rock with OpenCV.