Install OpenCV on Ubuntu Linux

This article is old. Please visit my new article revised: Install OpenCV on Ubuntu or Debian.

58 comments:

  1. Hi,

    Thanks for the tutorial..It was just what i needed to get Opencv installed.

    Great Job!!!

    Cheers

    ReplyDelete
  2. it took me a while, but got it running at last, you blog has help me a lot, Thank you

    ReplyDelete
  3. Nice article. Precise & Lucid !
    Great Work.
    Thanks.

    ReplyDelete
  4. Great!
    this is the best tutorial I ever seen about OpenCV.
    Thanks

    ReplyDelete
  5. at last getting error ... like
    https://www.dropbox.com/s/1yv0x60xz776qu7/Screenshot%20from%202013-09-12%2000%3A59%3A11.png

    ReplyDelete
    Replies
    1. It is because you don't apply correctly the step 5: Configure OpenCV.

      Delete
  6. Very good one...Thanks :-)

    ReplyDelete
  7. Hello, I am having problem with hough transform . can u help? it is giving some error

    ReplyDelete
  8. Hello, very nice manual
    However, in the example part, after ./build_all.sh I get this output

    g++: error: tbb: No such file or directory
    g++: error: rt: No such file or directory
    g++: error: pthread: No such file or directory
    g++: error: m: No such file or directory
    g++: error: dl: No such file or directory

    Can you please inform me about this error?

    ReplyDelete
    Replies
    1. Hi,Have you solved that error ?,I meet the same problem, can you tell me how to do with it?

      Delete
    2. Hi I've solved this problem by doing this
      First locate opencv.pc file, its usually in /usr/lib/../pkg-config/opencv.pc
      goto last but one line and it should be like this

      tbb rt pthread m dl

      Need to change this like below

      -ltbb -lrt -lpthread -lm -ldl

      Now try compiling it should work fine
      got this solution from some question in stackoverflow

      Delete
  9. I am getting the error of which Anonymous is getting up there ^ ?? Thanks in advance.

    ReplyDelete
    Replies
    1. Hi

      You guys should download opencv again, and make sure you compile with in the opencv directory i.e step 4

      Delete
  10. thank you!!! literally spent months trying to get it to work

    ReplyDelete
  11. hi all ,
    my name is hagai,
    I have run this steps ./facedetect lena.jpg
    i got this massage


    Illegal instruction (core dumped)
    can anyone help?

    ReplyDelete
  12. Thanks for this! saved me some time!

    ReplyDelete
  13. Thanks man... one of the best and easy way to install...i have some doubts related to the subject. Is there any blog of yours related to the opencv and opencv related programs.If it is there can you tell?

    ReplyDelete
  14. do we need any prerequisites before starting with the first step?
    coz wen i tried the step 2 it showed no such entry
    please help me

    ReplyDelete
  15. Thank you so much!!!!!

    ReplyDelete
  16. After I try to execute step 2 (installing the dependencies), I get the following error:

    Package 'libtbb-dev' has no installation candidate
    Unable to locate package libfaac-dev

    Are there some other dependencies that I need to install beforehand? Is the order of the dependencies incorrect?

    ReplyDelete
  17. thank you! works perfectly! saved me a lot of time!

    ReplyDelete
  18. Hi, I am having a problem when it comes to step 4 when i execute the command 'make'

    it gives me this error

    Linking CXX executable ../../bin/opencv_perf_gpu
    /usr/bin/ld: ../../lib/libopencv_highgui.so.2.4.3: don't know how to handle section ` ' [0x 2372]
    ../../lib/libopencv_highgui.so.2.4.3: could not read symbols: File in wrong format
    collect2: ld returned 1 exit status
    make[2]: *** [bin/opencv_perf_gpu] Error 1
    make[1]: *** [modules/gpu/CMakeFiles/opencv_perf_gpu.dor/all] Error 2
    make:: *** [all] Error 2

    i hope that you can help me resolve this problem as I need to rush with the completion of my project and opencv is a very important aspect of it, thanks so much for ur reply

    ReplyDelete
  19. 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

    http://namhuy.net/1205/how-to-install-opencv-on-ubuntu.html

    ReplyDelete
    Replies
    1. can this be the same for raspbian on raspberry pi too? thanks

      Delete
  20. while running samples/c file I m getting fatal error of file not found or directory not found can some one solve this problem

    ReplyDelete
  21. Thanks a bunch! I've been trying to install OpenCV on Win8 for the past four months but with no success. Now I'm on Ubuntu 13.10 and this really worked for me!

    ReplyDelete
  22. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. Thanks, I am also installed Opencv 2.4.8 in Ubuntu 13.10 Its worked......

      Delete
  23. THANK YOU VERY MUCH

    ReplyDelete
  24. Superb blog....Follow every word as it is and your are done

    ReplyDelete
  25. Thank you so much for your tutorial. This helped me a lot. perfect blog for openCV beginners.

    ReplyDelete
  26. help! I have this message error before passage 5:
    CMake Error at CMakeLists.txt:62 (include):
    include could not find load file:

    cmake/OpenCVUtils.cmake


    CMake Error at CMakeLists.txt:64 (ocv_clear_vars):
    Unknown CMake command "ocv_clear_vars".


    -- Configuring incomplete, errors occurred!
    what can I do?

    ReplyDelete
  27. When i try and run step 5, i get a permission denied error. any ideas?

    ReplyDelete
    Replies
    1. you need to enter sudo before the command, and it will work.

      Delete
  28. TY for this tutorial, simple, precise and helpful !

    ReplyDelete
  29. Hi, can I delete opencv folder after these steps?
    I'm using opencv with java, and cmake created both build/bin/opencv-249.jar and build/lib/libopencv_java249.so , but make didn't installed them in usr/local/... , or at least I coulnd't find them.
    I don't know where to copy theese files, nor if I have to copy more files in order to safe delete originally decompressed opencv directory.
    Thank you very much.

    ReplyDelete
  30. Great article, better than the official one that's for sure.

    Cheers

    ReplyDelete
  31. It worked thank u so much.......................... Great........

    ReplyDelete
  32. after i install openCV,can i use IDE such as Eclipse?

    ReplyDelete
    Replies
    1. Yes you can, I use Eclipse CDT (C++ IDE). If you have eclipse you can add cdt plugin, or you can download Eclipse with CDT. Here are some tutorials
      http://docs.opencv.org/2.4.9/doc/tutorials/introduction/table_of_content_introduction/table_of_content_introduction.html#table-of-content-introduction

      Delete
  33. sir i want to create a app that uses opencv to play virtual piano through gesture can u help me to do it plz ....sir

    ReplyDelete
  34. Am I missing something? Im getting the following


    [ 70%] Building CXX object modules/nonfree/CMakeFiles/opencv_perf_nonfree.dir/perf/perf_main.cpp.o
    In file included from /home/sello/opencv-2.4.9/modules/nonfree/perf/perf_main.cpp:28:0:
    /home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp: In function ‘void dumpOpenCLDevice()’:
    /home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:88:9: error: ‘PlatformsInfo’ is not a member of ‘cv::ocl’
    /home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:88:32: error: expected ‘;’ before ‘platforms’
    /home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:89:9: error: ‘getOpenCLPlatforms’ is not a member of ‘cv::ocl’
    /home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:89:37: error: ‘platforms’ was not declared in this scope
    /home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:95:19: error: ‘DevicesInfo’ in namespace ‘cv::ocl’ does not name a type
    /home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:96:39: error: ‘devices’ was not declared in this scope
    /home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:98:23: error: ‘DeviceInfo’ in namespace ‘cv::ocl’ does not name a type
    /home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:99:33: error: ‘current_device’ was not declared in this scope
    /home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:99:62: error: ‘CVCL_DEVICE_TYPE_CPU’ was not declared in this scope
    /home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:100:71: error: ‘CVCL_DEVICE_TYPE_GPU’ was not declared in this scope
    In file included from /home/sello/opencv-2.4.9/modules/nonfree/perf/perf_main.cpp:28:0:
    /home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:108:15: error: ‘DeviceInfo’ in namespace ‘cv::ocl’ does not name a type
    /home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:110:9: error: ‘deviceInfo’ was not declared in this scope
    /home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:111:9: error: ‘deviceInfo’ was not declared in this scope
    /home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:113:25: error: ‘deviceInfo’ was not declared in this scope
    /home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:113:50: error: ‘CVCL_DEVICE_TYPE_CPU’ was not declared in this scope
    /home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:114:61: error: ‘CVCL_DEVICE_TYPE_GPU’ was not declared in this scope
    make[2]: *** [modules/nonfree/CMakeFiles/opencv_perf_nonfree.dir/perf/perf_main.cpp.o] Error 1
    make[1]: *** [modules/nonfree/CMakeFiles/opencv_perf_nonfree.dir/all] Error 2
    make: *** [all] Error 2

    ReplyDelete
  35. Only blog that helped me with easy installation

    ReplyDelete
  36. Hi,
    thank you for this tutorial, very useful.
    I also have the problem that the "c" folder in the "samples" folder, is missing! So I can't run build_all.sh
    I have the "cpp" folder and in that is not working as well.
    Somebody have the solution?
    Thanks you in advance!

    Ubuntu 14 / OpenCV 3.0 alpha

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. I am having the same problem... whats the solution?

      Delete
  37. Is there a way to run a command line program that will return the number of faces in a picture?
    I would like to use it in a bash script and as far as I understand "facedetect" only shows you what is possible, it doesn't return boolean values like "there is a face" or "there isn't a face"
    Thank you!

    ReplyDelete
  38. When building OpenCV, you may want to add the job "-j" flag to the make command with the number of physical cores on your machine (i.e.make -j4) to decrease build time.

    ReplyDelete
  39. Very much informative steps for the installation of ubuntu linux. Thank you very much. Best IT company in coimbatore | Best web site developer

    ReplyDelete
  40. I like This Blog Posting. I Will Recommend This Post to Our Friends.Web Design Sydney

    ReplyDelete