[ubuntu] Google Chrome: Could not load plugin error fixed
Install Kinect on Ubuntu 12.10

A Comprehensive Tutorial of Installing OpenCV 2.4.3 in Ubuntu 12.10 [ i386 ]

Author posted @ 2013年2月17日 12:03 in Linux , 11926 阅读



(few modifications are made for 12.10 version ubuntu system here)

The Installation Procedure

To install and configure OpenCV 2.4.1, complete the following steps. The commands shown in each step can be copy and pasted directly into a Linux command line.

  1. Remove any installed versions of ffmpeg and x264.
    sudo apt-get remove ffmpeg x264 libx264-dev
  2. Get all the dependencies for x264 and ffmpeg.
    sudo apt-get update
    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
  3. Download and install gstreamer.
    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
  4. Download and install gtk.
    sudo apt-get install libgtk2.0-0 libgtk2.0-dev
  5. Download and install libjpeg.
    sudo apt-get install libjpeg8 libjpeg8-dev
  6. Create a directory to hold source code.
    cd ~
    mkdir src
  7. Download and install install x264.
    1. Download a recent stable snapshot of x264 from ftp://ftp.videolan.org/pub/videolan/x264/snapshots/. The exact version does not seem to matter. To write this guide, I used version x264-snapshot-20120528-2245-stable.tar.bz2, but I have used previous versions too.
          cd ~/src
          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
    2. Configure and build the x264 libraries.
      ./configure --enable-static
      sudo make install

      IMPORTANT: If you are running a 64-bit version of Ubuntu, you must configure x264 as shown in the following command

      ./configure --enable-shared --enable-pic
    3. The -shared and -pic options might also be required when you compile for some other architectures, such as ARM. You know you need these options if you get the following error when compiling OpenCV:

      [ 25%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/bitstrm.cpp.o
      Linking CXX shared library ../../lib/libopencv_highgui.so
      /usr/bin/ld: /usr/local/lib/libavcodec.a(avpacket.o): relocation R_X86_64_32S against `av_destruct_packet' can not be used when making a shared object; recompile with -fPIC
      /usr/local/lib/libavcodec.a: could not read symbols: Bad value
  8. Download and install install ffmpeg.
    1. Download ffmpeg version 0.11.1 from http://ffmpeg.org/download.html.
      cd ~/src
      wget http://ffmpeg.org/releases/ffmpeg-0.11.1.tar.bz2
      tar xvf ffmpeg-0.11.1.tar.bz2
      cd ffmpeg-0.11.1
    2. Configure and build ffmpeg.
      ./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
      sudo make install

      IMPORTANT: Just like with x264 in the previous step, you must configure ffmpeg with the -shared and -pic options if you are running a 64-bit version of Ubuntu or some other architectures, such as 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 --enable-pic
  9. Download and install install a recent version of v4l (video for linux) from http://www.linuxtv.org/downloads/v4l-utils/. For this guide I used version 0.9.3.
        cd ~/src
        wget http://www.linuxtv.org/downloads/v4l-utils/v4l-utils-0.9.3.tar.bz2
        tar xvf v4l-utils-0.9.3.tar.bz2
        cd v4l-utils-0.9.3
        sudo make install
  10. Download and install install OpenCV 2.4.3.
    1. Download OpenCV version 2.4.3 from http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.3/OpenCV-2.4.3.tar.bz2/download
          cd ~/src
          tar xvf OpenCV-2.4.2.tar.bz2
    2. Create a new build directory and run cmake:
      cd OpenCV-2.4.2/
      mkdir build
      cd build
    3. 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
    4. Build and install OpenCV.
      sudo make install
  11. Configure Linux.
    1. Tell linux where the shared libraries for OpenCV are located by entering the following shell command:
      export LD_LIBRARY_PATH=/usr/local/lib

      Add the command to your .bashrc file so that you don’t have to enter every time your start a new terminal.

      Alternatively, you can configure the system wide library search path. Using your favorite editor, add a single line containing the text /usr/local/lib to the end of a file named /etc/ld.so.conf.d/opencv.conf. In the standard Ubuntu install, the opencv.conf file does not exist; you need to create it. Using vi, for example, enter the following commands:

      sudo vi /etc/ld.so.conf.d/opencv.conf

      After editing the opencv.conf file, enter the following command:

      sudo ldconfig /etc/ld.so.conf
    2. Using your favorite editor, add the following two lines to the end of /etc/bash.bashrc:
          export PKG_CONFIG_PATH

After completing the previous steps, your system should be ready to compile code that uses the OpenCV libraries.


The following example shows one way to compile code for OpenCV:

g++ `pkg-config opencv --cflags` my_example.cpp -o my_example `pkg-config opencv --libs` 

Sample c++ file here, my_example.cpp, used for opening an image:

#include <stdio.h>
#include <opencv2/opencv.hpp>

using namespace cv;

int main( int argc, char** argv )
  Mat image;
  image = imread( argv[1], 1 );

  if( argc != 2 || !image.data )
      printf( "No image data \n" );
      return -1;

  namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
  imshow( "Display Image", image );


  return 0;

Once compiled, run command to see the sweetie :D

./my_example cLena.bmp

Luis 说:
2013年6月17日 00:46

Hey there, very nice post, just a configure is missing:

cd ~/src

wget http://www.linuxtv.org/downloads/v4l-utils/v4l-utils-0.9.3.tar.bz2

tar xvf v4l-utils-0.9.3.tar.bz2
cd v4l-utils-0.9.3
****** Here is the configure missing.
sudo make install

Thanks for the tutorial :)

Tim 说:
2013年7月01日 22:16

I just put ./configure --enable-shared --enable-pic again. It told me that --enable-pic didn't have any effect so you can probably leave it away.

Thanks for the tutorial!

Best Tim

鹅鹅 说:
2013年9月27日 16:22

@Luis: You are right, I just corrected it. Thank you. :)

johnny 说:
2013年11月26日 12:52

To install OpenCV using the terminal on Ubuntu:
$ su -
# apt-get update
# apt-get install build-essential
# apt-get install libavformat-dev
# apt-get install x264 v4l-utils ffmpeg
# apt-get install libcv2.3 libcvaux2.3 libhighgui2.3 python-opencv opencv-doc libcv-dev libcvaux-dev libhighgui-dev


Koksi 说:
2014年1月09日 11:36


I want to thank you for the detailed and well explained configuration for installing OpenCV! I followed your steps and I was able to run the application from the first time after all my failures! Warm thanks!!

Best regards,

Cheap tig welder 说:
2020年4月22日 08:32

Believe it or not, it is the kind of detail I've long been attempting to find. It matches my needs a whole lot. Thank you for composing this details.

JAC 10th Question Pa 说:
2022年8月17日 19:10

JAC 10th Question Paper 2023 Download – Jharkhand Matric Important Question Paper 2023 PDF, The State of Jharkhand came into existence on the 15th of November,2000. An Act to establish the Jharkhand Academic Council was enacted by the Jharkhand State Legislature and assented to by the Governor of the State on 26-12-2003, JAC 10th Question Paper 2023 which was known as Jharkhand Academic Council Act 02.7.2003.

anonymous 说:
2023年7月12日 06:59

Find the best essays on     is my friend's profile page. Termite Treatment Kissimmee

anonymous 说:
2023年7月31日 03:52

It is especially decent, though look into the tips during this home address. Virtual Tax Preparer

anonymous 说:
2023年8月15日 20:04

On my website you'll see similar texts, write what you think.  Interior car detailing near me

anonymous 说:
2023年8月18日 22:57

Oh man, this article is composed brilliantly. I have to salute the  here for doing a terrific job. I didn't think that was possible with the talent that he has, but he proved me wrong today. That's amazing. LCD screen

anonymous 说:
2023年8月22日 06:36

Best Drain Cleaning Services Sydney - Looking for a reliable blocked drain plumber in Sydney? We’ve got you covered! Unblock your drains and Blocked Toilet today. Blocked Drains Sydney

anonymous 说:
2023年8月24日 03:51

Our Sales Funnel Audit Documents Recommendations on site health, SEO, messaging, style guide, positioning and story. Read more about this.

Best Cheap Windows V 说:
2023年8月29日 23:42

The best cheap Windows VPS options typically come with robust hardware, advanced virtualization technology, ample resources, efficient support, and user-friendly management interfaces. They are well-suited for individuals or businesses seeking a budget-friendly Windows hosting solution without compromising on performance or reliability.

Canada VPS Windows 说:
2023年8月30日 01:13

Canada VPS Windows hosting combines the power of a virtual private server with the advantages of hosting your data in Canada. By choosing Canada as your server location, you benefit from low latency and fast connectivity for your Canadian audience. Additionally, Canada VPS Windows hosting ensures compliance with local data privacy laws, providing peace of mind and data sovereignty. With localized support and infrastructure, you can expect reliable performance and responsive customer service to address any issues or concerns promptly. Choose Canada VPS Windows hosting to cater to your Canadian users and take advantage of a secure and efficient hosting environment.

anonymous 说:
2023年9月01日 00:29

On that website page, you'll see your description, why not read through this. Massage tantra Genève

anonymous 说:
2023年9月11日 00:35

This is exciting, nevertheless it is vital for you to visit this specific url: best betting sites

anonymous 说:
2023年9月12日 05:04

In this case you will begin it is important, it again produces a web site a strong significant internet site: Hey Dudes Men's

anonymous 说:
2023年9月18日 01:25

Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... https://bitcoinbilgileri.com/top-10-cryptocurrencies-in-2023/

anonymous 说:
2023年12月17日 20:29

wow this saintly however ,I love your enter plus nice pics might be part personss negative love being defrent mind total poeple , Sydney sexy companions

登录 *

loading captcha image...
or Ctrl+Enter