Skip to content

Installing OpenCV 2.4.9 in Ubuntu 14.04 LTS

The latest Long Term Support version of Ubuntu(14.04 LTS) is out and a new version of OpenCV was recently released as well. This means that now is a great opportunity to update my OpenCV installation guide to the latest versions, Ubuntu 14.04 LTS and OpenCV 2.4.9.


One of the great additions in this new release of OpenCV is the new viz module, which offers a nice 3D visualizer. This module is based on the great Visualization Toolkit library (VTK) and nicely prepares the users for the upcoming OpenCV 3.

In this guide, I will show you how to install OpenCV with a lot of the features it provides. Here are some of the things that are going to be enabled when you are finished following through with this installation tutorial:

  • viz module (3D visualization)
  • Qt version of the HighGUI module (Better 2D window interface with zoom, image saving capabilities, etc)
  • OpenGL support
  • C++ interface and examples
  • C interface and examples
  • Python interface and examples
  • Java interface and examples
  • Intel Threading Building Blocks (TBB)

Note: I have noticed some copies of my posts elsewhere, so make sure that you are reading this from the original source, at samontab dot com, accessible from here so that you don’t miss the comments.

OK, so the first step is to make sure that everything in the system is updated and upgraded. Open the terminal and write this:

sudo apt-get update
sudo apt-get upgrade

Now, you need to install many dependencies, such as support for reading and writing image files, drawing on the screen, some needed tools, other libraries, etc… This step is very easy, you only need to write the following command in the Terminal:

sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen3-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev default-jdk ant libvtk5-qt4-dev

Time to get the OpenCV 2.4.9 source code:

cd ~
cd opencv-2.4.9

Now we have to generate the Makefile by using cmake. In here we can define which parts of OpenCV we want to compile. Since we want to use the viz module, Python, Java, TBB, OpenGL, Qt, work with videos, etc, here is where we need to set that. Just execute the following line at the terminal to create the appropriate Makefile. Note that there are two dots at the end of the line, it is an argument for the cmake program and it means the parent directory (because we are inside the build directory, and we want to refer to the OpenCV directory, which is its parent).

mkdir build
cd build


Check that the above command produces no error and that in particular it reports FFMPEG as YES. If this is not the case you will not be able to read or write videos. Check that Java, Python, TBB, OpenGL, V4L, OpenGL and Qt are all detected correctly.


Make sure you scroll up and check that the modules that are going to be built are these:
core flann imgproc highgui features2d calib3d ml video legacy objdetect photo gpu ocl nonfree contrib java python stitching superres ts videostab viz.

If anything is wrong, go back, correct the errors by maybe installing extra packages and then run cmake again.

Now, you are ready to compile and install OpenCV 2.4.9:

sudo make install

Now you have to configure OpenCV. First, open the opencv.conf file with the following code:

sudo gedit /etc/

Add the following line at the end of the file(it may be an empty file, that is ok) and then save it:


Run the following code to configure the library:

sudo ldconfig

Now you have to open another file:

sudo gedit /etc/bash.bashrc

Add these two lines at the end of the file and save it:


Finally, close the console and open a new one, restart the computer or logout and then login again. OpenCV will not work correctly until you do this.

Now you have OpenCV 2.4.9 installed in your computer with 3D visualization, Python, Java, TBB, OpenGL, video, and Qt support.

Check out the cool Qt interface which provides image viewing capabilities with zoom, as well as the ability to save the current image with just one click.

If you zoom in enough, you can see the RGB (or intensity) values for each pixel.

Now let’s build some samples included in OpenCV:

cd ~/opencv-2.4.9/samples/c
chmod +x
These examples use the old C interface:
./facedetect --cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml" --scale=1.5 lena.jpg

./facedetect --cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml" --nested-cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_eye.xml" --scale=1.5 lena.jpg

The following examples use the new C++ interface:

~/opencv-2.4.9/build/bin/cpp-example-grabcut ~/opencv-2.4.9/samples/cpp/lena.jpg


Now let’s run some Python code:

python ~/opencv-2.4.9/samples/python2/

Now you can build a Java sample using ant for example. (Make sure that you change /home/samontab/ with your actual home directory):

cd ~/opencv-2.4.9/samples/java/ant
ant -DocvJarDir=/home/samontab/opencv-2.4.9/build/bin -DocvLibDir=/home/samontab/opencv-2.4.9/build/lib


Now let’s read a video and use OpenGL with Qt through this great sample that detects the features from the video, then estimates the 3D location of the structure using POSIT, and finally uses OpenGL to draw in 3D (great sample Javier):

cd ~/opencv-2.4.9/samples/cpp/Qt_sample
mkdir build
cd build
cmake ..


And finally, let’s build a sample using the 3D visualization module viz:

cd ~/opencv-2.4.9/samples/cpp/tutorial_code/viz
g++ -o widget_pose `pkg-config opencv --cflags` widget_pose.cpp `pkg-config opencv --libs`


As you can see, now you can use OpenCV with C++, C, Python, and Java. The Qt enhanced 2D interface is enabled, 3D data can be displayed using OpenGL directly, or using the new viz module. Multi threading functionality is enabled using TBB. Also, video support is enabled as well.

If you correctly finished this tutorial, you are now ready to do some nice computer vision work.

Posted in Image Processing, Open Source, Programming, Qt.

118 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Jo says

    Thank you for your guide. I had really problems to get OpenCV work before and tried a bunch of other guides, but only yours worked in the end ;)

  2. samontab says

    You are welcome Jo. Great to hear that it worked for you.

  3. Pablo says

    Thanks for share.
    I was installing the OpenCV 2.4.9 in a cubieboard, with cubian (a debian fork) and with the help of your guide, it solve an issue.

    Thanks a great job

  4. samontab says

    Good job Pablo,

    Thanks for letting me know that this guide can also be applied to a cubieboard.

  5. Arbaaz Khan says

    I had mailed you a few days ago and while I managed the visualisation in matlab, this way of doing it with an integrated vtk is better. Thanks a ton for your help. :)

  6. samontab says

    Thanks Arbaaz Khan,

    I am glad it helped you.
    And, of course it is better, it is open source :)

  7. Arbaaz Khan says

    I’m having trouble with the reading a video through OpenGL and Qt. When I write the command ./OpenGL_Qt_Binding it says no such file exists. Also during build it shows support for qt and opengl and ffmpeg. What could the problem be ?

  8. samontab says

    Hi Arbaaz Khan,

    You are not providing enough information to generate a helpful answer.
    Most probably you missed a step, or you are using a different version of Ubuntu.
    From what you are saying, it may be that the executable is not being created for some reason. Do the other examples work?.
    Did you actually log out and log in again?
    Just follow every single step, line by line carefully in a fresh install of Ubuntu 14.04 LTS and it should just work.

  9. Toño says

    Your tutorial is great. But I have a error. This appear in the terminal.

    Linking CXX executable ../../bin/opencv_traincascade
    CMakeFiles/opencv_traincascade.dir/traincascade.cpp.o: no se reconoce el fichero: Fichero truncado
    collect2: error: ld returned 1 exit status
    make[2]: *** [bin/opencv_traincascade] Error 1
    make[1]: *** [apps/traincascade/CMakeFiles/opencv_traincascade.dir/all] Error 2
    make: *** [all] Error 2

  10. jeremy rutman says

    1000 blessings upon you for posting this.
    I get mostly thru , then hit
    “…By not providing “FindQt5Core.cmake” in CMAKE_MODULE_PATH this project has
    asked CMake to find a package configuration file provided by ‘Qt5Core’, but
    CMake did not find one…”
    upon trying the cmake. I did
    sudo apt-get install libboost-all-dev
    rm CMakeCache.txt
    and then the cmake again, same problem :{
    no clear answer on web search of that problem..

  11. samontab says

    Hello Jeremy,

    That is actually not an error, just a warning. It says that it can’t find Qt5, which is correct as it is not installed.
    That is fine as we are going to be using Qt4, which should be correctly installed and detected.
    Just ignore that message and continue, it should work as expected.

  12. samontab says

    Hello Toño,

    It seems that you have an incomplete download, or the file is somehow truncated.
    Try doing everything from scratch, and make sure that your download is complete.

  13. Seyedmajid says

    Thank you for your great tutorial for installing Opencv. I just encountered with problem in step cmake. I did it again but before this step several kinds of python were installed.
    I just have a problem now regarding samples. I ran all samples except one. everything has been done according to your tutorial but when running sample for OpenGL. I receive this problem : bash: ./OpenGL_Qt_Binding: No such file or directory

    :~/opencv-2.4.9/samples/cpp/Qt_sample/build$ ls
    CMakeCache.txt CMakeFiles cmake_install.cmake cube4.avi Makefile

  14. Seyedmajid says


    I wanted to test the core of Opencv by ./opencv_core_test
    at the end of the test just at the end it got a failed test reporting:[ FAILED ] 1 test, listed below:
    [ FAILED ] Core_globbing.accuracy . what is a problem? by the way I still have got my previous question posed in the other discussion forum in terms of one of samples using opengl. i executed all of samples after installing except this one. the output terminal says there is not opengl Qt directory in the made build.


  15. samontab says

    Hi Seyedmajid,

    It seems that you missed the make step.

  16. samontab says

    Hi Seyedmajid,

    There is nothing wrong with the code.
    The error in the test appears because testing is not completely setup.
    In particular, that test checks for particular files in OPENCV_TEST_DATA_PATH, but that path is not set. Nothing to worry about.
    If you want to learn more about that, take a look here:

  17. Umar Chughtai says


    Great tutorial. Unfortunately I also am having trouble when it comes to reading a video with OpenGL and Qt. This is the error I get.

    bash: ./OpenGL_Qt_Binding: No such file or directory

    Is removing and re-installing the only option? I mean everything else works.

  18. samontab says

    Hi Umar,

    It means that the file is not there. Maybe you had a compilation issue or maybe you forgot a step or two.

  19. Umar Chughtai says

    Thanks for a speedy reply!

    But here is whats funny here. The file actually does exits. By the name of OpenGL_Qt_Binding.dir , it exists in the CMakeFiles folder. What I don’t get is why it isn’t being recognized

  20. RobM says

    A few people have commented on the video / OpenGL / Qt example. I also had problems, the example code seems to be missing a “make” command which builds the example and creates the file OpenGL_Qt_Binding, which can then be executed.

    I think the sample code for that section should look like this:

    cd ~/opencv-2.4.9/samples/cpp/Qt_sample
    mkdir build
    cd build
    cmake ..

    Cheers. Really great guide. I had been unable to get OpenCV running on 14.04 until this guide.

  21. samontab says

    Hi Umar,

    You need to make the executable first. I was missing one line in the tutorial, I just updated it.

  22. samontab says

    Thanks for spotting it RobM. I just updated the tutorial.

  23. Rushil says

    Hello sam, thanks for posting this great tutorial!

    So while following steps everything went great until i tried building the samples using:
    1 cd ~/opencv-2.4.9/samples/c
    2 chmod +x
    3 ./

    After which I start getting bombarded with errors similar to:
    compilation terminated.
    compiling smiledetect.cpp
    Package opencv was not found in the pkg-config search path.
    Perhaps you should add the directory containing `opencv.pc’
    to the PKG_CONFIG_PATH environment variable
    No package ‘opencv’ found
    Package opencv was not found in the pkg-config search path.
    Perhaps you should add the directory containing `opencv.pc’
    to the PKG_CONFIG_PATH environment variable
    No package ‘opencv’ found
    smiledetect.cpp:1:43: fatal error: opencv2/objdetect/objdetect.hpp: No such file or directory
    #include “opencv2/objdetect/objdetect.hpp

    Where did I go wrong?

  24. samontab says

    Hello Rushil,

    It seems to me that the startup scripts were not called. Maybe you forgot to logout and login, or restart the machine before continuing the tutorial.
    Try this command:
    pkg-config --libs opencv
    It should tell you where the OpenCV libraries are installed. If that does not work, fix it by looking at that part of the tutorial, otherwise the will not work.

  25. Rushil says

    Hey sam,

    I had not installed all the VTK packages.
    I downloaded them and it works like a charm now.


  26. baran says

    hello i really need ur help

    my system is 12.10 and i get cmake warning

    Looking for ffmpeg/avformat.h – not found

    i really need your help please..

  27. RB says

    Nice tutorial although it is missing additional information on some quite notorious issues such as the FFMPEG support. OpenCV usually (always? :D) requires some older version of the FFMPEG library that is currently installed on most people’s systems so you are quite often forced to seek out which version exactly you have to download, build and install in order for the OpenCV’s compilation procedure not to throw some poop in your face with FFMPEG somewhere between the lines in the resulting error messages. Some of the header files are also often not found concering:


    Some of these can be resolved by manually editing as a root various files but it is ugly and tedious. I’m currently using Debian Wheezy and of course these issues are present. Switched from Ubuntu 12.04 LTS quite recently and there these very same problems were also present. If you look on the internet you will see that most people, who claim that their compilation process was successful, actually have these problems (you can catch their nonsense by looking at their terminal output of the cmake and make phases if any were provided). I’m curious if you had the same issues. If not, you are one hell of a lucky guy! LOL

  28. samontab says

    Hi RB,

    I actually did not find any issue at all. I am using the standard FFMPEG libraries from the Ubuntu repositories and it is working fine.
    I wouldn’t call it luck though, just documenting what I am doing and reproducing it from scratch to make sure that it works.

    Here for example I was using an older version of FFMPEG:

  29. samontab says

    Great to hear that it worked Rushil

  30. Andrew says

    Hi. What should I do to configure Qt project for using with opencv?

  31. samontab says

    Hi Andrew,

    Just create a makefile for your project. Once you do that, you will be able to open that file with Qt.

  32. Passiday says

    Thank you for this elaborate guide, Sebastian! I hear that when working with Python, it is suggested to use virtual environments whenever possible. Can you, please, point out how to correctly install OpenCV in a Python virtualenv?

  33. Ganesh Babu says

    Well, it worked, thanks for the time you spent.. keep following your site, keep new things posted………..

  34. omar says

    Is this method still working in the case of ubuntu 64bit?
    Can you make a tutorial on how to configure codeblock IDE with openCV 2.4.9

  35. wang qaing says

    when i make it turns out errors that “relocation R_X86_64_32 against `.rodata.str1.1′ can not be used when making a shared object; recompile with -fPIC” can you help me? thank you

  36. samontab says

    Hi Omar,

    I created the guide using Ubuntu 14.04 LTS 64 bits, so it should work.
    Codeblocks is just an IDE, so it should work exactly the same as with any other library.

  37. samontab says

    Thanks Ganesh Babu

  38. samontab says

    Thanks Passiday,

    Using this guide you will have python and OpenCV installed system wide. I haven’t installed it on a python virtual environment, so I don’t have the instructions for you, sorry.

  39. samontab says

    Hi wang qaing,

    Well, you are either compiling it with other options, or in another environment or OS since it should just work.
    You could try adding -fPIC to the compilation line as suggested by the compiler.

  40. Josimar says

    Thank you for the guide. I tried it and I works.

    I’m using Qt Creator like IDE, I can compile openCV files but the windows of OpenCV doesn’t show it.

    Could you help me?

  41. Sarvottam Patel says

    Thank you very much, finally it worked for my UBUNTU 14.04 ,However it cost me 2 days but, a nice experience.

  42. marilu597 says

    Amazing guide. Thanks a lot!

  43. jaidev joshi says

    Thousand likes for the great tutorial thanks for making our life easier.

  44. Stuart Butler says

    Thanks Sebastian. This is a great guide.

    I’ve created a docker image using it:

  45. Hector says

    Thanks for the guide, It was very useful. But I still have
    some problems with it. I have a laptop with a cuda capable
    card with cuda 6.5 version, I got the installation to work but
    when I try to compile the examples, the following is shown:

    /usr/bin/ld: no se puede encontrar -lcufft
    /usr/bin/ld: no se puede encontrar -lnpps
    /usr/bin/ld: no se puede encontrar -lnppi
    /usr/bin/ld: no se puede encontrar -lnppc
    /usr/bin/ld: no se puede encontrar -lcudart
    collect2: error: ld returned 1 exit status

    If you could help me It would be great. Thanks in advance.

    PD: The installation worked but I had to modify NCVPixelOperations.hpp
    source code.

  46. samontab says

    Hi Hector,

    The compiler can’t find those libraries. It seems that they are all related to cuda. Check that you have enabled the cuda module in the compilation of opencv, and that the cuda libraries are correctly installed system wide, or if not, add the cuda libs path to the compiler with -L/path/to/cuda/libs in the compilation line.

  47. loijing says

    from cv import *
    ImportError: No module named cv

    i try tu sample program which included in the package, but i got the above given error type.
    I follow all the installation steps given by you.

  48. StonJarks says

    Just wanted to say thank you! Great guide. Works perfect!

  49. samontab says

    You are welcome StonJarks

  50. samontab says

    Hi loijing,

    It does not find the cv module. Probably you missed one of the steps of the tutorial.
    Check that BUILD_NEW_PYTHON_SUPPORT=ON and that you already restarted the pc (or logout-login)

  51. samontab says

    Hi Hector,

    I don’t have access to a cuda enabled machine at the moment, so I can’t really give you an exact answer but it seems that the linker is not finding the cuda libraries.

    You would need to do something like this:
    g++ main.cpp -L/path/to/cudalibs -lcufft -lnpps ... etc...

    Where -L is specifying a path for the libraries that you want to use. That’s the path that the linker is not getting.

    If you don’t know where the libraries are, you can try with something like this:

    locate libcufft

    That should tell you where that file is.

    And of course, make sure that you have the development libraries for cuda installed!.

    PS: What were the changes that you made to NCVPixelOperations.hpp?, maybe somebody else will need that as well.

  52. Paul Saunders says

    Hi Sebastian
    Thanks so much for putting a usable guide together, that just works! :-) I have used your previous for 12.04 also and that worked flawlessly too…
    You write (in relation to dependencies): “This step is very easy, you only need to write the following command in the Terminal”. Very true, but are you prepared tell us a little more on how you worked out what the dependencies are/should be? That is the crucial part for me and I feel I would be much more productive if I could figure all that out for myself…
    Thanks again and keep up the good work! ;-)

  53. samontab says

    Hello Paul,

    Thanks for your kind words.
    In regards what you are asking, it is usually just experience with linux in general. You get to know which libraries are needed for certain things. Also, there are a few libraries or programs that are very specific to the actual version that you are installing and that you have to research a bit to get them.
    For example, things like cmake or build-essential are almost always needed to build anything. Other libraries are relatively common like libjpeg-dev libtiff4-dev, which allow reading and writing jpeg and tiff image formats for example. By the way, generally the packages that end with “-dev” install the development files for that program.
    Also, you could try using cmake-gui which is a GUI for cmake and lists all the option the program has (if it using cmake). That way you can have an idea of what libraries it should need.
    And lastly, I recommend you using virtual machines as you can always create snapshots, try something, and go back in time if something went wrong, or you don’t know how to undo something you did.

  54. hamzeh says

    When using make i just receive the following answer:
    -bash: make: command not found

  55. samontab says

    Hi hamzeh,

    You probably skipped the initial installation of the needed tools. At least you should install this to have make:
    sudo apt-get install build-essential

  56. Daisuke Tsuji says


  57. Selina says

    Thank you very much. I just follow your step, it works very well.
    I also set OPENNI on, which is often used with Kinect.
    I follow this post

    It will be great if you can also combine this one into your post, then it is more comprehensive.

  58. Keegan.Ren says

    god,may be you can add pcl with all of about you compile.

  59. hamzeh says

    thank you very much
    but i still need your help because there is somthing wronge
    i insall this command “sudo apt-get install build-essential” but it doesn’t generate makefile
    i just again receive the following answer:
    -bash: make: command not found

  60. samontab says

    Hello hamzeh,

    You don’t have the required programs to compile it. Make sure that you install them first. This is done at the beginning of the tutorial.

  61. samontab says

    Hi Keegan.Ren,

    Sure, I can. Maybe in another post.

  62. samontab says

    You can use Qt 5 as well with OpenCV.

  63. mxer says

    So glad you published this. Sometimes I just want a hassle-free install, and this was truly the ticket.

  64. Assma says

    Thank you very much mr samontab. it works very nice. I like to work with OpenCV and Ubuntu, I am a condidate Ph.D in Computer Vision

  65. samontab says

    Glad to hear it worked for you mxer.

  66. samontab says

    All the best, Assma.

  67. Girmaw says

    Thanks man, you have been very helpful for along time, for varieties of opencv and ubuntu versions.

  68. samontab says

    Thanks Girmaw!

  69. doo-sol Lee says

    hi. Thank you for your guide.
    but i have some problem.
    when I typed ‘make’
    I found error…

    In file included from /usr/include/qt4/QtOpenGL/QtOpenGL:5:0,
    from /home/ubuntu/opencv-2.4.9/modules/highgui/src/window_QT.h:46,
    from /home/ubuntu/opencv-2.4.9/modules/highgui/src/window_QT.cpp:47:
    /usr/include/qt4/QtOpenGL/qgl.h:85:17: error: ‘GLdouble’ has a previous declaration as ‘typedef GLfloat GLdouble’
    typedef GLfloat GLdouble;
    In file included from /usr/include/GL/gl.h:2059:0,
    from /usr/include/GL/glx.h:32,
    from /home/ubuntu/opencv-2.4.9/modules/highgui/src/window_QT.cpp:59:
    /usr/include/GL/glext.h:468:19: error: conflicting declaration ‘typedef std::ptrdiff_t GLsizeiptr’
    typedef ptrdiff_t GLsizeiptr;
    In file included from /usr/include/qt4/QtOpenGL/qgl.h:79:0,
    from /usr/include/qt4/QtOpenGL/QtOpenGL:5,
    from /home/ubuntu/opencv-2.4.9/modules/highgui/src/window_QT.h:46,
    from /home/ubuntu/opencv-2.4.9/modules/highgui/src/window_QT.cpp:47:
    /usr/include/GLES2/gl2.h:69:25: error: ‘GLsizeiptr’ has a previous declaration as ‘typedef khronos_ssize_t GLsizeiptr’
    typedef khronos_ssize_t GLsizeiptr;
    In file included from /usr/include/GL/gl.h:2059:0,
    from /usr/include/GL/glx.h:32,
    from /home/ubuntu/opencv-2.4.9/modules/highgui/src/window_QT.cpp:59:
    /usr/include/GL/glext.h:469:19: error: conflicting declaration ‘typedef std::ptrdiff_t GLintptr’
    typedef ptrdiff_t GLintptr;
    In file included from /usr/include/qt4/QtOpenGL/qgl.h:79:0,
    from /usr/include/qt4/QtOpenGL/QtOpenGL:5,
    from /home/ubuntu/opencv-2.4.9/modules/highgui/src/window_QT.h:46,
    from /home/ubuntu/opencv-2.4.9/modules/highgui/src/window_QT.cpp:47:
    /usr/include/GLES2/gl2.h:70:26: error: ‘GLintptr’ has a previous declaration as ‘typedef khronos_intptr_t GLintptr’
    typedef khronos_intptr_t GLintptr;
    make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_QT.cpp.o] Error 1
    make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
    make: *** [all] Error 2

    can you help me??

  70. samontab says

    Hi doo-sol Lee,

    It seems that the system is not finding OpenGL.
    Make sure that the cmake option for OpenGL is there (WITH_OPENGL=ON) and that you correctly installed all the dependencies at the beginning.
    Also, make sure that you are using these specific versions: Ubuntu 14.04 LTS, and OpenCV 2.4.9. The guide should still work in other environments, but with those versions, it is copy paste ready :)

  71. doo-sol Lee says

    Hi, again me…
    thank you for your reply.
    I’m working on bealglebone Board.(based on ARM cortex-A8)
    I istalled bone-ubuntu-14.04.1-console-armhf-2014-10-29-2gb.img on beaglebone board.
    You said that I had to install Ubuntu LTS 14.04.
    Then, your guide is unsuitable to me?
    sorry for my poor English…

  72. samontab says

    Hi doo-sol Lee,

    That is a completely different environment. You can use the tutorial as a guide, but definitely it will not work just copy pasting it.
    Some libraries that OpenCV requires may not be there in your repositories, and so on.

  73. saurabh says

    awesome tutorial man..

  74. samontab says

    Thanks saurabh

  75. Armando says

    Hi when i try to build my code I have this error message:
    “OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file /hdd/buildbot/slaves/slave_jetson_tk1/52-O4T-L4T/opencv/modules/highgui/src/window.cpp, line 483
    terminate called after throwing an instance of ‘cv::Exception’
    what(): /hdd/buildbot/slaves/slave_jetson_tk1/52-O4T-L4T/opencv/modules/highgui/src/window.cpp:483: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvNamedWindow”

    What is this? what can i do to solve it

  76. samontab says

    Hi Armando,

    It seems that you did not install any library for managing windows, which is needed by HighGUI.
    Just re compile opencv by following this tutorial line by line, and it should work. Don’t skip any part of it.

  77. KV says

    Hi.. This helped me a lot,..Thank you so much.
    We want to pull the data from facebook and using pulled data edit the sample video with facebook pictures and play in the browser. Sample video has placeholders which is moving . I have to track the placeholder’s position using openCV and have to replace it with facebook pictures.
    Is it possible to use open CV with html5 and python? If you have any tutorial for that,Please share..
    Thank you so much again..

  78. Rene says

    hy, this is a great tutorial – many thanks.

    Unfortunately i have the same troubles as Armando has (one post prior)

    OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file /home/rene/Ubuntu_System/opencv-2.4.10/modules/highgui/src/window.cpp, line 483
    terminate called after throwing an instance of ‘cv::Exception’
    what(): /home/rene/Ubuntu_System/opencv-2.4.10/modules/highgui/src/window.cpp:483: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvNamedWindow

    Aborted (core dumped)

    ARMANDO, do you have any ideas so far how to solve this?

    Many thanks!!!

  79. Rene says

    ..its me again :-)

    i tried the 2 cpp-examples and they worked fine.

    So am i am right, if i assume that only namedWindow-commands will not work?
    does this mean my opencv-installation is fine actually?
    dows this mean i could work with programs, which do not require windows?

    many thanks for your help!

  80. Rama Krishna Reddy says

    The best guide for beginners …. Thanks for helping beginners like me. Keep doing good work.

  81. hotice says

    Works with OpenCv 2.4.10 too. Just replace 2.4.9 to 2.4.10 while executing commands on terminal.

    Tested in Ubuntu Gnome 14.04 and Xubuntu 14.04

  82. Javier says

    Hi! I followed the tutorial and everything worked with no errors but I don’t have the java folder inside the build folder and I need it in order to work with eclipse.. Do you know why this happened?

  83. samontab says

    Hi Javier,
    Probably you did not include Java in the cmake step.

  84. samontab says

    Thanks for that hotice.

  85. samontab says

    You are welcome Rama Krishna Reddy

  86. samontab says

    Hi Rene,
    If you just copy and paste the instructions, it should work. At least using OpenCV 2.4.9 under Ubuntu 14.04 LTS. If you use any other distro or version of OpenCV, it should still work, but you should know what you are doing, and check every step.
    The error that you are showing here is related to a GUI. Try the suggested solution (sudo apt-get install libgtk2.0-dev pkg-config) and then re run the tutorial.

  87. samontab says

    Hi Rene,

    It seems that the only error is GUI related, so you may use the library for the rest of the functionality. Although, I would not recommend using it because who knows what else is missing. Highgui is the module for GUI and also for I/O, so reading and writing images and video, and also reading from keyboard and mouse. I recommend you to install opencv properly first.

    By the way, do you need to use the latest OpenCV?, otherwise just use the included pre compiled version from the application manager!

  88. samontab says

    Hi KV,
    Of course you can use OpenCV for that, but OpenCV will only deal with the image processing part, you should take care of the web interface.
    Having said that, probably OpenCV is not the ideal candidate for that particular task. Maybe something like imagemagick would be easier to use in your case.

  89. Gabriel Martins says

    Hi! Thanks for the tutorial. I just got a problem.
    All examples run great. But that from Qt_sample is giving error in OpenGL. I also run other examples that uses OpenGL and no problem appeared. I used CMake like you and added the flag WITH_OPENGL=ON and received a YES(that was reconized). Do you know what this problem can be? Sorry for the english. Ty

  90. samontab says

    Hi Gabriel,

    Hard to tell without the exact error.

  91. Gabriel Martins says

    I just got this:
    after cmake ..
    — The C compiler identification is GNU 4.8.2
    — The CXX compiler identification is GNU 4.8.2
    — Check for working C compiler: /usr/bin/cc
    — Check for working C compiler: /usr/bin/cc — works
    — Detecting C compiler ABI info
    — Detecting C compiler ABI info – done
    — Check for working CXX compiler: /usr/bin/c++
    — Check for working CXX compiler: /usr/bin/c++ — works
    — Detecting CXX compiler ABI info
    — Detecting CXX compiler ABI info – done
    — Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/
    — Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/ – found
    — Looking for gethostbyname
    — Looking for gethostbyname – found
    — Looking for connect
    — Looking for connect – found
    — Looking for remove
    — Looking for remove – found
    — Looking for shmat
    — Looking for shmat – found
    — Looking for IceConnectionNumber in ICE
    — Looking for IceConnectionNumber in ICE – found
    — Found X11: /usr/lib/x86_64-linux-gnu/
    — Found OpenGL: /usr/lib/x86_64-linux-gnu/
    — Configuring done
    — Generating done
    — Build files have been written to: /home/gabriel-pc/Documentos/opencv-2.4.9/samples/cpp/Qt_sample/build
    after ./ ..
    OpenCV Error: No OpenGL support (Library was built without OpenGL support) in cvNamedWindow, file /home/gabriel-pc/Documentos/OpenCV/opencv/modules/highgui/src/window_gtk.cpp, line 845
    terminate called after throwing an instance of ‘cv::Exception’
    what(): /home/gabriel-pc/Documentos/OpenCV/opencv/modules/highgui/src/window_gtk.cpp:845: error: (-218) Library was built without OpenGL support in function cvNamedWindow

    Abortado (imagem do núcleo gravada)

  92. Majed says

    Hi Samon

    You defintely did great job. You should be proud of it. I personally appreciate your work.

    Thank you so much dear.


  93. PRIME says

    Your guide is on point. Keep it up!

  94. Jonathan says

    Thanks for a great guide, very precise and the only one of many that actually worked for me ;)

  95. Dmitry says

    Install libqt5opengl5-dev on ubuntu 14.04

  96. samontab says

    Hi Dmitry,

    You can still use Qt 4.8 on Ubuntu 14.04. Of course Qt5 can be used as well, but there are a few projects that still depend on the older Qt 4.8.

  97. samontab says

    You are welcome Jonathan

  98. samontab says

    Thanks PRIME

  99. samontab says

    Thanks Majed

  100. samontab says

    Hi Gabriel,

    It seems that OpenGL is not being detected, or not being selected.

  101. Roka says

    Thank you very much for your guide, it was very helpful. I have followed the instructions of many tutoriels but none works. You guide is perfect, thank you again.

  102. samontab says

    You are welcome Roka. I’m glad it worked for you too.

  103. Caleb H. says

    Regarding the error about ‘-fPIC’, it seems that when configuring/building ffmpeg, you need to include ‘–enabled-shared’. This is mentioned in an older version of this guide:

    Where the full configure command for ffmeg is:
    ./configure –enable-gpl –enable-version3 –enable-nonfree –enable-postproc –enable-libfaac –enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libtheora –enable-libvorbis –enable-libxvid –enable-x11grab –enable-swscale –enable-shared

    Thanks for the awesome tutorial!

  104. Roberto says

    Thanks a lot, it worked like a charm!

  105. Thomas says

    Thanks alot, this was really helpful

  106. samontab says

    Hi Caleb,

    I think you are right.

  107. samontab says

    You are welcome Roberto

  108. samontab says

    You are welcome Thomas

  109. Hensly Jemio says

    Hi, Sebastian I am just trying to learn OpenCV through your video course, however trying to install the 2.4.9 version. Everything worked well till I’ve tried to run the Facedetect executes but at the end this sentence appears:
    init done
    opengl support available
    In image read
    Illegal instruction <—-THIS

    And nothing happens. I've tried the contours, polar_transforms and they work..guessing I could say that the problem involves some type of raster managing function..please give me a hand

  110. samontab says

    Hello Hensly,

    Great to hear that you are using my videos. I hope they are useful for you.

    About your specific issue, it seems that it is somehow related to reading an image from disk. Try using a webcam or a video file.
    If that also does not work, try using a different model file (I am refering to the xml that represents the object).

  111. someone says

    Thank you su much samontab. It’s a great tutorial for beginners

  112. jsparks says

    The weath of examples provided with opencv are increadible, your guide provides the perfect jumpstart.

Continuing the Discussion

  1. Installing OpenCV 2.4.1 in Ubuntu 12.04 LTS – Sebastian Montabone linked to this post on June 24, 2014

    […] EDIT: I published a new guide using Ubuntu 14.04LTS and OpenCV 2.4.9 here. […]

  2. Install OpenCV with QT | XI linked to this post on November 10, 2014

    […] Here is a very good instruction for installing OpenCV 2.4.9.  One thing to be aware is the options of setting cmake. In the post, QT is set ON by command -D WITH_QT=ON. Whereas, the version of this QT is 4.x, but newest QT library is 5.2. With the QT option on, when compiling OpenCV program in QT Creator, the program will crash with errors like realloc(): invalid pointer. Hence, make sure to set WITH_QT=OFF.  […]

  3. How to compile OpenCV 2.4.10 on Ubuntu 14.04 and 14.10 - linked to this post on December 11, 2014

    […] Sebastian Montabone's writeup […]

Some HTML is OK

or, reply to this post via trackback.