:::: MENU ::::

Installing OpenCV 3.0.0 on Ubuntu 14.04

Posted in October 15, 2014

In this article, we’ll see how to install the computer vision library OpenCV 3.0.0 alpha, latest release, released two months ago (Ago 21, 2014) , on Ubuntu 14.04 LTS (Trusty Tahr) 64 bits. For those who already have installed previous releases, you’ll see that, basically, nothing has changed and it’s as easy as always. Watch the demonstration video to see how it works.

-- Tested on Ubuntu 12.04, 14.04 LTS 64 bits and 32 bits, 14.10, 15.04, 16.04 Amazon EC2 Ubuntu 14.04;
-- Thanks to all users that tested this script on their system and gave me a feedback! Really thanks!
-- Tested on release 3.0.0 alpha, beta and gold of OpenCV;
-- A Dockerfile is also provided by TJ Borromeo (Thanks!) used in OpenCV bindings for node.js

-- Ubuntu 14.04 LTS 64 bits or 32 bits installed and updated;

Lets get it started!

As I wrote in the pre-requirements, is always nice to have your OS updated. Then, run apt-get update and apt-get upgrade before we really start. For those who already have it done, skip this and don’t forget to comment these lines from the script if you choose to use it.

1st step: Install the Dependencies

To install the dependencies required from OpenCV, just run the following commands:

sudo apt-get -y install libopencv-dev build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libtiff4-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip

2nd step: Download OpenCV 3.0.0 alpha

You can download manually or run the commands below to get OpenCV:

mkdir opencv
cd opencv
wget https://github.com/Itseez/opencv/archive/3.0.0-alpha.zip -O opencv-3.0.0-alpha.zip
unzip opencv-3.0.0-alpha.zip

3rd step: Install OpenCV

Now, we’ll install OpenCV. Cmake command has a lot of options: choose those that better suit your needs and run the commands below. If you’re planning to use Qt 5.x, don’t use -D WITH_QT=ON. Learn how to use OpenCV 3 with Qt Creator 3.2 (Qt 5.3). [Update] According to one of the users that tested it on Ubuntu 14.10, you’ll need to use WITH_FFMPEG=OFF. [Update] BUILD_NEW_PYTHON_SUPPORT is no longer used.

cd opencv-3.0.0-alpha
mkdir build
cd build
make -j $(nproc)
sudo make install

4rd step: Finishing installation

To get OpenCV working properly, we need to tell Ubuntu:

sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig

After all is done I recommend rebooting your system. Done!
Then, you might be wondering: “So, that’s it?” Yes!

If you prefer, you can download the script below. If you do so, you’ll see that in addition to installing OpenCV, the script will generate a log for you, to know  how long did it take. At the end of this post you’ll see a demonstration video of the installation and test.

Script - Install OpenCV 3.0.0 (20169 downloads)

Lets test it!

We will test to check if everything is working properly. Doesn’t matter if I say you should do this way if it doesn’t work, right? Come on! I’m assuming you just restart your computer after you have performed the above steps or the given script.

1st test: Running an OpenCV sample

First of all, we need to compile the samples. Worth saying that the commands below can be avoided by adding the options to build samples on the 3rd step of installation.

cd opencv/opencv-3.0.0-alpha/samples/
sudo cmake .
sudo make -j $(nproc)

Now you can run a sample. I chose two, but feel free to run any other. The goal here is to prove that our OpenCV installation was a success. The samples we’re going to run are the FaceDetect and HoughtLines developed in C++.

cd cpp/
./cpp-example-facedetect lena.jpg // (../data/lena.jpg) OpenCV 3.0 beta
./cpp-example-houghlines pic1.png // (../data/pic1.jpg) OpenCV 3.0 beta

Note 1: If you’re using OpenCV 3.0 beta, both images are inside “../data/” directory;
Note 2: To close the window with Lenna, just press ENTER. The same to finish HoughLines. Go on and run other samples;

2nd test:  Running our own program

What about compiling something we made? Just below I am providing a simple program whose purpose is to display an image. Unzip it and run the commands below inside the folder you just created.

sudo cmake .
sudo make
./DisplayImage lena.jpg

If everything went right, you’ll see Lenna. Press ENTER to close.

OpenCV - DisplayImage Sample (6388 downloads)

Watch the demonstration video to see how it worked on my computer. I chose to run the script.

We did it! OpenCV installed and tested.

Questions? Leave your comment or get in touch by email.

Test setup:
-- Intel Core i5 2.6GHz
-- 4GB of RAM
-- 160GB of hard disk

  • dmigous


    Does anybody know what plugin is missing in my case?

    OpenCV Error: Unspecified error (GStreamer: your gstreamer installation is missing a required plugin
    ) in handlemessage, file /home/ubuntu/workspace/opencv/modules/videoio/src/cap_gstreamer.cpp, line 1692
    terminate called after throwing an instance of ‘cv::Exception’
    what(): /home/ubuntu/workspace/opencv/modules/videoio/src/cap_gstreamer.cpp:1692: error: (-2) GStreamer: your gstreamer installation is missing a required plugin
    in function handlemessage

  • anand

    when trying to compile a program it’s showing following error what is the problem ?please help me to resolve the problem

    bash: ./cpp-example-facedetect: No such file or directory

  • Huemmer Santana

    Thanks man! Great tutorial! In the 1st step, the packages libtiff4-dev and libxine-dev weren’t identified for Ubuntu. I had to change to libtiff4-dev and libxine2-dev.

  • Francesco Piva

    it is possible to install it on Odroid (ARM architecture?)

  • bruno

    Everything went fine till the end of the installation (i’ve put the more recent opencv-2.4.13), but if try your tests to see if it works it gives me problem everythime i enter the command “sudo cmake”

  • ahsan

    First of all , thanks , opencv working fine and samples are running. Can someone tell me how to configure opencv with spyder? whenever I use “import cv2″ , it gives me error ” no module named cv2″. I know how to do in windows but can’t do in linux. In windows we have to copy cv2.pyd file in python’s sub folder and edit environment variable
    Thanks in anticipation

  • liz

    after I run cmake ., then make, I get the error:

    CMakeFiles/DisplayImage.dir/DisplayImage.cpp.o: In function `main’:
    DisplayImage.cpp:(.text+0x5f): undefined reference to `cv::imread(cv::String const&, int)’
    DisplayImage.cpp:(.text+0xd0): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)’
    and more undefined references. I included all the header files from the tutorial.

  • Deepak Sharma

    Thanks for your blog. I am facing trouble for while configuring cuda7.5 with this opencv 3.0. Please tell me how I can make necessary settings for running cuda examples in eclipse.

    • What exactly is wrong? Do you have any error message? Can you run them out of the IDE?

  • Ravi Teja

    Hello! Thanks so much for this blog. Helped me to install opencv properly! However, when I tried commands like import cv or import cv2 or import opencv in the python shell in ubuntu, I got errors saying No module name … I have also tried to import in Pycharm which uses Python 3.4 but am facing the same problem. How can I actually run python scripts using opencv? Do I need to save them in the opencv folder everytime? Thanks again!

  • Will Jefferson

    Hi, So after I do the third step (Install OpenCV), the install goes up to 67% but then the Terminal says “make: *** [all] Error 2” and stops installing the remaining items. I’ve tried many times from scratch, and it always gets stuck on the third step. Any tips? Thanks!

    • I’d need more information about the error. What is the error?


    Today (may 30, 2016) it works well on Ubuntu 16.04 LTS , I just had to change 2 dependencies: libqt4-dev by libqt5-dev & libxine-dev by libxine2-dev. And one trouble to run: sudo /bin/bash -c ‘echo “/usr/local/lib” > /etc/ld.so.conf.d/opencv.conf’ but I solved that updating /etc/hostname. ¡Thanks a lot!

  • Probal Sikder

    Works like charm for opencv 3.0.1 in ubuntu 14.04. Thanks a ton Rodrigo 🙂

  • Shabnam Nazmi

    Hi Rodrigo,
    Thank you so much for your helpful instruction. I’ve
    been struggling with installing Open-CV on my Ubuntu instance on Amazon
    cloud for more than a week and tried several tutorials, but this one is just so neat and honestly working. I have just this problem
    that the (sudo make install) command on step 3 returns,

    Make: *** No Rule to make target ‘install’. Stop.

    other previous
    steps are executed correctly without errors. Could you please help me
    figure out what is the problem? thank you in advance and looking for
    your reply.

  • Murillo Cota Ferreira (Cota)

    Rodrigo, eu estou começando agora com o opencv e instalei tudo certinho, consegui carregar uma imagem, rodei os exemplos, mas agora estou seguindo os tutoriais na página oficial do opencv e estou tendo muitos problemas, nos tutoriais eles estão usando o visual studio no windows e eu to achando que o código está dando erro. Minha dúvida é se as funções do opencv são as mesmas nas bibliotecas tanto do windows quanto no linux. Tem alguma adaptação de código necessária?

    • Olá Murilo, não. Nenhuma adaptação é necessária. Se quiser, me mande um email com sua dificuldade.

      • Murillo Cota Ferreira

        já consegui resolver o problema, obrigado

      • Qualquer coisa, é só falar…

      • Murillo Cota Ferreira


  • Pingback: OpenCV + Qt Creator [Menampilkan Citra/Gambar] – qt-linux-programming-etc()

  • Parth Parekh

    Hello, C++ examples run fine but when I try to run a python sample, I get the following error

    cv2.error: ——-src-dir——-/opencv-2.4.10/modules/highgui/src/window.cpp:501: 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 cvShowImage.
    I followed the instructions but still doesnt work. Thanks

  • Andre

    Sorry i am preaty new at this. I did the instalation sucessfully and i work with some of the examples, but now i would like to uninstall it.
    I just cant do it. Can u help please?

    • Hi Andre, you can run ‘make uninstall’ on the same directory you ran ‘make’ or you can delete every single file that contains ‘opencv’ in the filename: ‘sudo find / -name “*opencv*” -exec rm -i {} ;’

  • Dongik Shin

    Hi Rodrigo. Your posting says “If you’re planning to use Qt 5.x, don’t use -D WITH_QT=ON.” Would you give me more details? The words are somewhat contradictory to me. Thank you.

  • sameer

    hey bro!!after executing the .sh file , i tried to test it ,but when i type:

    sudo make -j $(nproc)
    i get the error:
    make: *** No targets specified and no makefile found. Stop.

  • roby

    hi ,great post . could you post some info about compile debug _build for opencv?

  • Parth Parekh

    Hi, Great tutorial. The test examples run fine but when I try to execute any python example, I get an error – ImportError -/home/parth/.local/lib/python2.7/site-packages/numpy/random/mtrand.so: undefined symbol: PyFPE_jbuf

  • amrutha

    Hi Rodrigo, I have installed openCv as per your instruction but for ./cpp-example-facedetect lena.jpg its giving me an error saying that “bash: ./cpp-example-facedetect: No such file or directory”

  • Luis Eduardo

    Hiiii 😀 all work for me 😀 just perfect!!! thanks, the only thing is than I could’t run the 1st Test, I suppouse because the 3.0.0 version don’t have the Lena image and the other one, but the 2nd test ran well 🙂
    I did it with the next:
    Ubuntu 14.04 64 bits
    OpenCV 3.0.0 (2015) downloaded directly from the opencv official site
    And following all the steps and recomendations 🙂

  • Wanderson Souza

    What’s going on?

    collect2: error: ld returned 1 exit status
    make [2]: *** [cpp / cpp-example-detect_mser] Error 1
    make [1]: *** [cpp / CMakeFiles / example_detect_mser.dir / all] Error 2
    make [1]: *** Waiting for unfinished jobs ….
    [34%] Built target example_inpaint
    [34%] [35%] Built target example_imagelist_creator
    Built target example_intelperc_capture
    make: *** [all] Error 2

  • Stephen Wilkerson

    I think it’s a path issue. Not sure. Will take to work and see if I can get some help. Everything installs no issues, but when I import cv2 I get an error. I’m on a Raspberry Pi-2 running Jessie. Works in Ubuntu so I’m using that right now.
    Anyhow, I for one greatly appreciate all of the great people like you that take the time to show the rest of us how to do things, so I just wanted to say thanks. If I figure out what the issue is I’ll post it. Best wishes,

    • Thanks. Good luck. If you need help, ask here or send me an email.

  • Stephen Wilkerson

    Doesn’t work on a Raspberry PI, but thanks

    • That’s sad to know. If you don’t mind to share what went wrong, I’d be very grateful.

  • Mayibongwe Handy

    Hi, i get a error after inputting the second command of the first set …

    “libgtk2.0-dev: command not found “.

    • The error is self-explanatory: apt-get install libgtk2.0-dev

  • blink_me

    Please, what is the build directory? I must run this code:

    OpenCV_DIR=”” luarocks install cv

    (I don’t know why the extra quotes show up when I copy/paste the command?)

    From here: https://github.com/VisionLabs/torch-opencv/wiki/installation

    • If you used my script, the build directory is “opencv/opencv-{version}/build” (e.g.: “opencv/opencv-3.0.0-alpha/build”)

      • blink_me

        Thank you for your fast response, this helped 🙂

  • Evangeline

    The 2nd test (Running our own program) didn’t work out for me .. i got =>(( CMake Error at CMakeLists.txt:11 (ocv_check_dependencies):
    Unknown CMake command “ocv_check_dependencies”.)) and when i type ./DisplayImage lena.jpg i got=> ((bash: ./DisplayImage: No such file or directory)) although i used cmake for the 1st test and it worked fine !!!?

    • That’s weird, because the CMakeLists I provide has no calls to `ocv_check_dependencies`. Are you sure it happens on the sample I provide?

      • Evangeline

        yeah , well i restart it and i redo the 2nd test and it works now !! thank you

      • 🙂

  • Pingback: Detecção de rosto com a webcam usando python e opencv - Blog da Nokitua()

  • Mohamed Elaskily

    i am tring to run a script on Matlab and this script use opencv, i install opencv 3.0 and when i running the script it gives an error

    Processing: dataset/MICC-F220/CRW_4853tamp1.jpg (1/220)
    lib/sift/bin/siftfeat: error while loading shared libraries: libopencv_core.so.2.3: cannot open shared object file: No such file or directory

    • I’ve never used OpenCV with Matlab, but looks like it is looking for OpenCV 2.3, not 3.0. Are you sure Matlab is trying to link to the correct version?

  • Kaira

    I installed opencv 3.0.0 on Ubuntu 14.04, but now I need to come back to opencv 2.4.11, so can u suggest how to uninstall opencv 3. or is there any method to use both OpenCV 2.4.8 and OpenCV 3 simultaneously on the same system.

    • If you still have the installation files, you can run ‘make uninstall’ from the same place you ran ‘make install’. And Yes, you can maintain both versions and switch between them pretty easily using cvswitch (https://github.com/uavster/cvswitch). I did that once and is pretty easy to use.

  • Pingback: Ubuntu 14.04 Üzerine OpenCV 3.0ve QT Kurulumu | Fevzi Daş()

  • Pingback: Installing OpenCV 3.0.0 with NVIDIA CUDA 7.5 on Ubuntu 14.04 64bit | diluka7()

  • Markios

    How can I do to add ROS dependencies for using cv bridge with your CMake mode? I’m new to ROS and I know how to do it with catkin but not with only make and cmake

    • I’m sorry, but I’ve never used OpenCV alongside with ROS

  • Roger

    Getting “command not found” when running: python-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libtiff4-dev libjasper-dev

    • You should run the entire command… or use at the end of each line, if you want to copy-n-paste line by line

  • Debasish Opu

    I’ve installed opencv by following your instruction. But when I’m testing it and running this command “./cpp-example-facedetect lena.jpg // (../data/lena.jpg) OpenCV 3.0 beta” terminal is showing “bash: syntax error near unexpected token `(‘ “.

    • You should run without the comment, just “./cpp-example-facedetect lena.jpg”

  • Amar Yadav

    after installing Opencv when i am going to check according to your instructions ——->./cpp-example-facedetect lena.jpg //

    i am getting this errors———-> This program demonstrates the cascade recognizer. Now you can use Haar or LBP features.
    This classifier can recognize many kinds of rigid objects, once the appropriate classifier is trained.
    It’s most known use is for faces.
    ./facedetect [–cascade= this is the primary trained classifier such as frontal face]
    [–nested-cascade[=nested_cascade_path this an optional secondary classifier such as eyes]]

    see facedetect.cmd for one call:
    ./facedetect –cascade=”../../data/haarcascades/haarcascade_frontalface_alt.xml” –nested-cascade=”../../data/haarcascades/haarcascade_eye.xml” –scale=1.3

    During execution:
    Hit any key to quit.
    Using OpenCV version 3.0.0-alpha

    Processing 1 lena.jpg
    Processing 2 //
    Failed to load OpenCL runtime
    init done
    opengl support available
    In capture …
    OpenCV Error: Unspecified error (GStreamer: unable to start pipeline
    ) in icvStartPipeline, file /home/ashish/opencv_alpha/opencv-3.0.0-alpha/modules/videoio/src/cap_gstreamer.cpp, line 399
    terminate called after throwing an instance of ‘cv::Exception’
    what(): /home/ashish/opencv_alpha/opencv-3.0.0-alpha/modules/videoio/src/cap_gstreamer.cpp:399: error: (-2) GStreamer: unable to start pipeline
    in function icvStartPipeline

    Aborted (core dumped)
    please help me how to fix this

  • Blacky_i

    Thanks for this man! you saved my time!

  • 鐘阿泰

    I don’t find videoio.h, how should i do thanks
    /home/ubunhtu/opencv-3.0.0/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:25: fatal error: sys/videoio.h: No such file or directory


  • Raghu

    i am new to ubuntu, i have build the libraries as you have mentioned. but where to write new program in which directory i have save it?, and how to compile that new program.

    • Any directory. You just need to compile your program linking to the libraries used, or use `pkg-config –cflags –libs opencv`.

  • How can I fix this problem on using my webcam

    init done

    opengl support available

    Frame Size = 640×480

    GStreamer Plugin: Embedded video playback halted; module filesink0 reported: Could not open file “D:/MyVideo.avi” for writing.

    OpenCV Error: Unspecified error (GStreamer: cannot put pipeline to play

    ) in CvVideoWriter_GStreamer::open, file /home/david/Desktop/opencv-3.0.0/opencv/modules/videoio/src/cap_gstreamer.cpp, line 1459

    terminate called after throwing an instance of ‘cv::Exception’

    what(): /home/david/Desktop/opencv-3.0.0/opencv/modules/videoio/src/cap_gstreamer.cpp:1459: error: (-2) GStreamer: cannot put pipeline to play

    in function CvVideoWriter_GStreamer::open

    • As the error says: Could not open file “D:/MyVideo.avi” for writing.

  • hello for some reason im getting this output,

    Gstreamer Plugin: embedded video playback halted; module filesink0 reported:could not open file “MyVideo.avi” for writting.
    OpenCV Error: unspecified error (GStreamer: cannot put pipeline to play) in CvVideoWriter_Gstreamer::open, file

    this is my code:

    #include “opencv2/highgui/highgui.hpp”
    #include “opencv2/core/core.hpp”

    using namespace cv;
    using namespace std;

    int main()
    VideoCapture cap(0); // open the video camera no. 0

    if (!cap.isOpened()) // if not success, exit program
    cout << "ERROR: Cannot open the video file" << endl;
    return -1;

    namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"

    double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
    double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video

    cout << "Frame Size = " << dWidth << "x" << dHeight << endl;

    Size frameSize(static_cast(dWidth), static_cast(dHeight));

    VideoWriter oVideoWriter (“D:/MyVideo.avi”, CV_FOURCC(‘P’,’I’,’M’,’1′), 20, frameSize, true); //initialize the VideoWriter object

    if ( !oVideoWriter.isOpened() ) //if not initialize the VideoWriter successfully, exit the program
    cout << "ERROR: Failed to write the video" << endl;
    return -1;

    while (1)

    Mat frame;

    bool bSuccess = cap.read(frame); // read a new frame from video

    if (!bSuccess) //if not success, break loop
    cout << "ERROR: Cannot read a frame from video file" << endl;

    oVideoWriter.write(frame); //writer the frame into the file

    imshow("MyVideo", frame); //show the frame in "MyVideo" window

    if (waitKey(10) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
    cout << "esc key is pressed by user" << endl;

    return 0;


    • OpenCV couldn’t create the file. Try a different path or a different codec.

  • grfiv

    When I upgraded to Ubuntu 15.10, opencv 3.0.0 no longer worked.

    I tried to rebuild it from scratch and I got a flood of warnings and messages and the make process failed at 18%.

    When I tried including -D WITH_CUDA=OFF I still got a flood of warnings but the process ran to completion and everything worked again.

  • Oc Jay

    I keep getting error messages on test 1 but test 2 works fine..please help a noob

    user@TV-PCu:~/opencv/opencv-3.0.0-alpha/samples/cpp$ ./cpp-examples-facedetect leana.jpg

    bash: ./cpp-examples-facedetect: No such file or directory

    user@TV-PCu:~/opencv/opencv-3.0.0-alpha/samples/cpp$ ls

    3calibration.cpp image.cpp polar_transforms.cpp

    airplane.jpg imagelist_creator.cpp puzzle.png

    baboon200.jpg image_sequence.cpp right01.jpg

    baboon200_rotated.jpg inpaint.cpp right02.jpg

    baboon.jpg intelperc_capture.cpp right03.jpg

    bgfg_segm.cpp intrinsics.yml right04.jpg

    board.jpg kalman.cpp right05.jpg

    box_in_scene.png kmeans.cpp right06.jpg

    box.png laplace.cpp right07.jpg

    building.jpg left01.jpg right08.jpg

    calibration.cpp left02.jpg right09.jpg

    camshiftdemo.cpp left03.jpg right11.jpg

    cloning_demo.cpp left04.jpg right12.jpg

    cloning_gui.cpp left05.jpg right13.jpg

    CMakeCache.txt left06.jpg right14.jpg

    CMakeFiles left07.jpg scene_l.bmp

    CMakeLists.txt left08.jpg scene_r.bmp

    CMakeLists.txt~ left09.jpg segment_objects.cpp

    connected_components.cpp left11.jpg select3dobj.cpp

    contours2.cpp left12.jpg shape_example.cpp

    convexhull.cpp left13.jpg shape_sample

    cout_mat.cpp left14.jpg smiledetect.cpp

    create_mask.cpp lena.jpg squares.cpp

    dbt_face_detection.cpp letter_recog.cpp starter_imagelist.cpp

    delaunay2.cpp letter-recognition.data starter_video.cpp

    demhist.cpp lkdemo.cpp stereo_calib.cpp

    dft.cpp logo_in_clutter.png stereo_calib.xml

    distrans.cpp logo.png stereo_match.cpp

    drawing.cpp lsd_lines.cpp stitching.cpp

    edge.cpp memorial.exr stitching_detailed.cpp

    em.cpp minarea.cpp stuff.jpg

    facedetect.cpp morphology2.cpp templ.png

    fback.cpp npr_demo.cpp train_HOG.cpp

    ffilldemo.cpp opencv_version.cpp tree.avi

    filestorage.cpp openni_capture.cpp tree_engine.cpp

    fitellipse.cpp pca.cpp tsukuba_l.png

    fruits.jpg phase_corr.cpp tsukuba_r.png

    grabcut.cpp pic1.png tutorial_code

    graf1.png pic2.png tvl1_optical_flow.cpp

    graf3.png pic3.png ufacedetect.cpp

    H1to3p.xml pic4.png videostab.cpp

    houghcircles.cpp pic5.png watershed.cpp

    houghlines.cpp pic6.png waveform.data

    image_alignment.cpp points_classifier.cpp


  • Leo

    With this tutorial and some substitution (libtiff5-dev, libxine2 and wget https://github.com/Itseez/opencv/archive/3.0.0.zip without alpha) and now I can use OpenCV with Ubuntu Mate…on my Raspberry Pi 2

  • Aminudin Muh

    I have some problems, in my terminal shows “capture AVI didn’t work” I hope you can help me solve this

    • Are you sure the path to lena.jpg is correct? This tutorial was made using OpenCV 3.0 alpha. Beta and gold versions moved all data files to a “data” directory in the “samples” directory.

      • Aminudin Muh

        I installed opencv 3.0 gold version, I have moved all data files to data dirctory samples but it still didn’t work
        maybe you have another way to solve this problem

      • If so, you should have changed “lena.jpg” to “../data/lena.jpg” as stated on the post. This is the only possible mistake, given your error. Check the source-code of the sample.

      • Aminudin Muh

        ok, I will try it
        thanks a lot

  • Rami Nsouli

    Dear Rodrigo,
    Thank you for your marvelous guide (worked better than most others), I successfully installed opencv3.0 on my Ubunto 14.04 (32GB HDD, 4GB RAM is virtual machine on windows ), I also tried the cpp samples and I could see face detection on lena.jpg successfully, but it is not working on PYTHON … no matter what I try (no module named cv2, no module named numpy, etc).

    Any help is appreciated.

    • Was python installed before OpenCV? Otherwise, you’ll need to copy ‘cv2’ file from ‘opencv3/build/python/…” to ‘site-packages’ that is in your Python directory.

  • Rami Nsouli

    Dear Rodrigo, thank you for your marvelous guide. It worked better than most other guides installing opencv, but although my installation was successful (after several attempts), when I try to import from python is says: ImportError: No module named ‘cv2’

    I tried to search for cv2 [sudo find / -name cv2 ] and there was no results coming back.
    I have opencv-3.0.0 on 14.04 trusty.

    Should I reinstall the entire thing??
    any help is much appreciated.

    • Was python installed before OpenCV? Otherwise, you’ll need to copy ‘cv2’ file from ‘opencv3/build/python/…” to ‘site-packages’ that is in your Python directory. OpenCV only does that for you if Python was previously installed, obviously.

  • Jay

    cd opencv-3.0.0-alpha
    mkdir build
    cd build
    cmake (…)
    i get the output:
    CMake Error: The source directory “/home/janis/opencv/opencv-3.0.0-alpha/build/WITH_OPENGL=ON” does not exist.

    • Christian Inostroza

      i have the same problem 🙁

  • GS099

    Hi…I’m getting a

    nvcc fatal : Unsupported gpu architecture ‘compute_11’
    CMake Error at cuda_compile_generated_gpu_mat.cu.o.cmake:208 (message):
    Error generating

    during the make -j $(nproc) process….any ideas how to fix this?


  • Did you import nonfree module?

  • grfiv

    After following your lovely instructions for 3.0.0 on an Amazon EC2 Ubuntu 14.04 instance, Python could not find the cv2 module (import cv2 failed).

    Here’s what worked:

    sudo find / -name “cv2.so”
    nano .bashrc
    export PYTHONPATH=/home/ubuntu/opencv/opencv-3.0.0/build/lib:$PYTHONPATH

    source ~/.bashrc

    • Good to know how to make it work on Amazon EC2… thanks!

  • Jitendra Mishra

    how opencv extra modules can install in ubuntu 14.04 if opencv is already install ?

  • Prabhash

    Thanks for the wonderful tutorial. opencv installation went seamless.
    However, when i run the opencv samples program i get the following error:

    : cannot connect to X server :0.0

    Pls help.

  • Sahla Thasnim

    i tried to execute sample program asift.py (python)….but it gets an error AttributeError: ‘module’ object has no attribute ‘SIFT’

  • Prabhash Thakur

    Hello Rodrigo,

    OpenCV 3.0 installation went all fine on Ubuntu 14.04.

    I was also able to run few simple opencv programs.

    But i face problem with tbb. One of my programs gives the following cmake error:
    — The C compiler identification is GNU 4.8.4

    — The CXX compiler identification is GNU 4.8.4

    — 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 Q_WS_X11

    — Looking for Q_WS_X11 – found

    — Looking for Q_WS_WIN

    — Looking for Q_WS_WIN – not found

    — Looking for Q_WS_QWS

    — Looking for Q_WS_QWS – not found

    — Looking for Q_WS_MAC

    — Looking for Q_WS_MAC – not found

    — Found Qt4: /usr/bin/qmake (found version “4.8.6”)

    CMake Warning at src/CMakeLists.txt:2 (find_package):

    By not providing “FindTBB.cmake” in CMAKE_MODULE_PATH this project has

    asked CMake to find a package configuration file provided by “TBB”, but

    CMake did not find one.

    Could not find a package configuration file provided by “TBB” with any of

    the following names:



    Add the installation prefix of “TBB” to CMAKE_PREFIX_PATH or set “TBB_DIR”

    to a directory containing one of the above files. If “TBB” provides a

    separate development package or SDK, be sure it has been installed.

    — Found Eigen3: /usr/include/eigen3 (Required is at least version “2.91.0”)

    — Configuring done

    — Generating done

    Note: I’ve installed the tbb devel library as mentioned in your steps.

    Could you please look into the same and share your observations.

    Thank you.

  • ToastToast

    The official documentation should redirect here!

  • jguo

    really helpful, thanks.

  • Shawn Le

    thanks for a great tutorial!

    can we also install version 3.0 with previous version already available? any conflict? or need to remove the old one?

  • Aniket Sharma

    Thumbs up for the tutorial! 🙂

  • Rodolfo

    how can i install opencv 3.0.0 for to can use the multi core procesing, because when i use open cv in linux onlu use one core and i have 8 cores. Im using the odroid xu3.

  • THANK YOU, Rodrigo! I was not able to build and test opencv 3.0 until I read this tutorial.

  • Looks like this tool uses OpenCV 2.4.2.
    You’ll probably need to update some headers to use with OpenCV 3. Maybe even change some code.

  • Schlomo Glickstein

    thanks, also works mostly for opencv 3.0.0 on ubuntu 15.04. remove libtiff4-dev and libxine-dev from list of dependencies. change all references to 3.0.0-alpha.zip into 3.0.0.zip and you are on track for a clean compile. thanks again

  • Hi Rodrigo,

    I tried your method on Lubuntu 14.04 with the current OpenCV 3.0.0 stable version. Everything worked fine. The sample codes you have given also got compiled. I also successfully compiled your sample codes and other codes I have written using g++ using the following command from the command line prompt : g++ xyz.cpp -o xyz `pkg-config –cflags –libs opencv`. Besides, I was able to call opencv from codelite by setting the Linker Options to `pkg-config –cflags –libs opencv` in the project settings of codelite project.

    A big thank you!


  • Sadegh Mohammadi

    Rodrigo! the tutorial is the best ever! works amazingly good! I just got a small issue,
    I am followed the instruction and opencv3 is installed perfectly! I am trying to lunch a toolbox called DenseTrajectory (http://lear.inrialpes.fr/people/wang/dense_trajectories)
    but in the “make” step I get the error like: DenseTrack.cpp:112:36: error: ‘cvtColor’ was not declared in this scopecvtColor(image, grey, CV_BGR2GRAY);
    and many error like this which show that I opencv cannot communicate with the file to make the file.

    Do you have anyidea, how I can solve this issue?

  • David Jepherson

    I’ve got anaconda and matlab in my latptop how to consider these things when cmake for opencv?
    with the present cmake it doesn’t find matlab and also find the default address of python not that in the anaconda directory

  • Pingback: Add FaceRecognition Module in opencv | Solutions for enthusiast and professional programmers()

  • Subhrajit Bhattacharya

    Thank you so much. Everything worked completely smoothly.

  • Dennis Povshedny

    Thank you Rodrigo for the great step-by-step instruction!

    It worked for me for Ubuntu 14.02 and OpenCV-3.0.0-rc1.

    The only thing I would correct is NOT to use “sudo” in tests. At least it worked for me without sudo-ing.


    • Thanks. SUDO-ing is really unnecessary on those cases, you’re right.

  • Rafael Capretz

    Perfect tutorial Rodrigo. It worked great under Linux Mint 16. Thanks a million

  • Indraraj

    Thanks for your post. When I try to run sample files I have ‘./cpp-example-facedetect: command not found’ error. Can you please help ???

  • tigist

    Thanks Rodrigo.
    I need a little bit of help on Running an OpenCV sample.
    I get the error below when I do ‘sudo cmake .’ from the samples directory.

    CMake Error at cpp/CMakeLists.txt:11 (ocv_check_dependencies):
    Unknown CMake command “ocv_check_dependencies”.

    — Configuring incomplete, errors occurred!

    can you help please??

    • Felipe

      Me too. What should we do?

  • Pingback: 【笔记】Installing OpenCV 3.0.0 on Ubuntu 14.04 – 向右走()

  • Pingback: Install programming tools on ubuntu14.04 | 小茶馆-热点新闻即时更新,百姓生活畅所欲言()

  • Shah Nawaz

    I have successfully installed and run the sample code. Can you please share how we can run our own code considering I am new with ubuntu

  • kapila

    inside opencv/opencv-3.0.0-alpha/samples/… samplecodes worked.but downloading your own code not working.return “No such file or director” .

    • The return “No such file or directory” means OpenCV is working properly and is telling you that the file you’re trying to read is not where it is supposed to be. Just a path problem, not an OpenCV problem. Try to adjust the path to the image.

  • Bo Zhou

    I have GTX980 and run into error ‘mvcc fatal : Unsupported gnu architecture ‘compute_11”, by adding -D CUDA_GENERATION=Auto to the cmake command fixed the problem

    • Thx for sharing!

    • asdf

      I also came across the same error ‘mvcc fatal : Unsupported gnu architecture ‘compute_11”, but instead I added -D CUDA_ARCH_BIN=3.5 -D CUDA_ARCH_PTX=3.5 to fix the problem (the capability of K40c is 3.5).

  • grfiv

    Very nice. Thank you.

    • You’re welcome. Thanks for reading and watching!

      • grfiv

        I notice that SIFT and others are missing from 3.0 and I am told that the cmake must change to include them. Do you know how your script should be updated to accomplish this? Thanks

      • Sure. So far, these modules are available at https://github.com/itseez/opencv_contrib and need to be more stable to be included as part of the official distribution. Follow the README to rerun the cmake.

  • Maj Id

    Hi Rodrigo,

    Thanks for your instruction. it worked for me but when I want to use my own written c++ program by employing
    g++ ‘pkg-config opencv –cflags’ hello_opencv.cpp -o hello_opencv ‘pkg-config opencv –libs’
    I get error. why?

    the program is in the part below:
    using namespace std;
    using namespace cv;
    int main(int argc, char **argv)
    Mat im = imread(“image.jpg”, CV_LOAD_IMAGE_COLOR);
    imshow(“Hello”, im);
    cout << "Press 'q' to quit…" << endl;
    if(char(waitKey(1)) == 'q') break;
    return 0;
    I'm trying to learn OpenCV by reading the book: Practical OpenCV by Samarth Brahmbhatt.
    I really appreciate it if you could help me out.
    Thanks already.

    • Could you please provide information about the error?

      • Maj Id

        for sure. “I have the image.jpg in the same directory.” by the way I could run the two samples you’ve provided.
        g ++: error: pkg-config opencv –cflags: File or directory not found
        g ++: error: pkg-config –libs opencv: File or directory not found

      • I don’t know… if the samples worked, this also should be working for you. Check the output of these commands and see if the files are there. Did you try to use the cmake provided on this tutorial with your program?

      • Maj Id

        what is the output of g++?

        I only used the vim to write the program hello_opencv.cpp and then tried to run it via g++. I have also put the image.jpg in the corresponding folder. I didn’t try it firs but later with cmake I got this message:

        :~/workspace/Vim /opencv projects$ sudo cmake .
        CMake Error: The source directory “/home/majid/workspace/vim /opencv-projects” does not appear to contain CMakeLists.txt.
        Specify –help for usage, or press the help button on the CMake GUI.

        which is still not possible to run my own program. by the way I tried opencv with eclipse and everything went right.

    • Giovanni Alexis Perez Montt

      you need this symbol ` `

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

      or you can too with cmake compiler 🙂

  • gin

    None of the test work

    • Could you please provide more information? If you prefer, you can send me an email.

  • Asma GAIDI

    Hi Rodrigo ,thanx a lot for this tuto , it was workfull for me. I want to ask you about some modules who are not supported in opencv 3.0.0 like “xfeatered” who allow me to use the SURF fonctions. I was trying to build those modules with my opencv 3.0.0 by following the read me here https://github.com/Itseez/opencv_contrib ,but I have errors and the second step ( cmake -DOPENCV_EXTRA_MODULES_PATH=……) does not work for me and bring me errors…
    Can you help me please ?

    • Email me with more information, such as the erros and what have you tried, ok?

      • Asma GAIDI


      • Guest

        I just send to you an email , can you check it please

      • Asma GAIDI

        I sent you an email yesterday can you check it please ?

      • Nothing here. Send again.

    • Could you get this solved?

      • Asma GAIDI

        No unfortunately, I didn’t resolved despite I tried many solutions. So I installed another version (2.10) to progress in my work.

  • olga

    Thank yoy for useful post, but i have some problems. Would you help me, please?

    1) I was trying to install opencv using this instruction http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation

    but I have ‘make’ errors, i wrote about it here http://answers.opencv.org/question/56452/installation-make-error-ubuntu-1404/

    2) then I found your tutorial and run script, but I also have same errors. I have got no ideas how to solve it :(((

    errors like this:

    [ 23%] Building CXX object modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/src/grfmt_jpeg.cpp.o
    /home/olga/libs/openCV/opencv/opencv-3.0.0-alpha/modules/imgcodecs/src/grfmt_jpeg.cpp: In function ‘void cv::jpeg_buffer_src(j_decompress_ptr, cv::JpegSource*)’:
    /home/olga/libs/openCV/opencv/opencv-3.0.0-alpha/modules/imgcodecs/src/grfmt_jpeg.cpp:150:29: error: invalid conversion from ‘void (*)(j_decompress_ptr) {aka void (*)(jpeg_decompress_struct*)}’ to ‘void (*)()’ [-fpermissive]
    make[2]: *** [modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/src/grfmt_jpeg.cpp.o] Error 1
    make[1]: *** [modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/all] Error 2
    make: *** [all] Error 2

    • Sorry olga, but I’ve never seen this before. Do you mind to make sure sudo apt-get install -y libjpeg-dev ran ok?
      Could you please send me the entire cmake and make outputs in a txt file? Send to my email.

      • olga

        I send to your email my ‘error’ report

      • olga

        I reinstalled Ubuntu 14.04 and used your script, and it work!!!

      • I feel like there’s nothing better than a fresh Ubuntu to install something new 🙂

  • Leroy

    When I try to do this: ./cpp-example-facedetect lena.jpg

    Terminal show me this error message: bash: ./cpp-example-facedetect: No such file or directory
    But the file exists!!

    • Are you sure both cpp-example-facedetect (not only the .cpp version) and lena.jpg are within the directory? If you prefer, email me with a printscreen or a ‘ls’ txt output.

  • Pingback: Travis CIでOpenCV + GTest + Coverallsを実行する方法 | tatsyblog()

  • Aman Verma

    when i try to run python code failed to load opencll runtime .. then some lines of error then last line is ‘module’ object has no attribute ‘CV_AA’

    • Which code are you trying to run? Some modules are not fully supported in OpenCV 3 Python (e.g.: ML). If you prefer, you can email me with full error and source code.


      OpenCV 3 has changed anti alias line attribute name from CV_AA into LINE_AA. You have to do that too.

  • Aman Verma

    when i make , it throws multiple errors each having the format CODEC_ID_* was not declared in this scope. what should i do . please help ?

    • Are you using Ubuntu 14.10? It’s an API problem from libav. I’ve never tried, but some people say that building ‘ffmpeg’ from source solve this problem. Could you try?

      For installing ffmpeg you should download its sources from official site or clone GIT repository (git://source.ffmpeg.org/ffmpeg.git), then enter source directory and run

      ./configure –enable-shared –disable-static
      sudo make install

      Instructions from: http://stackoverflow.com/a/27020828

  • Tejeswini Sundaram

    Hey Rodrigo, I was following your tutorial for setting up openCV 3.0-beta version. I ran into an error while i ran the make -j$(nproc) step.

    This is what gets printed on my screen:

    — checking for module ‘gstreamer-base-1.0’

    — package ‘gstreamer-base-1.0’ not found

    — checking for module ‘gstreamer-video-1.0’

    — package ‘gstreamer-video-1.0’ not found

    — checking for module ‘gstreamer-app-1.0’

    — package ‘gstreamer-app-1.0’ not found

    — checking for module ‘gstreamer-riff-1.0’

    — package ‘gstreamer-riff-1.0’ not found

    — checking for module ‘gstreamer-pbutils-1.0’

    — package ‘gstreamer-pbutils-1.0’ not found

    — Looking for sys/videoio.h

    — Looking for sys/videoio.h – not found

    — Looking for libavformat/avformat.h

    — Looking for libavformat/avformat.h – found

    — Looking for ffmpeg/avformat.h

    — Looking for ffmpeg/avformat.h – not found

    Any suggestions on how to install these modules would be very helpful.


    • Looks like you skipped the 1st step or something went wrong on the 1st step. Install the dependencies and try to make again.

      • Tejeswini Sundaram

        Hey, I tried installing the dependencies that were not found. I found that few of the dependencies where unavailable to install via “sudo apt-get install” as my OS was not upgraded. I did an upgrade and then all things worked smoothly. I successfully installed OpenCV 3.0.0 beta version on Ubuntu 14.04.

        Thanks for the help.


      • Glad to hear that everything is working!

  • Diego

    Hello Rodrigo, I don’t know if I failed using or installing something or missing any command, however while testing the programs, when I use ‘sudo cmake .’ it doesn’t appear all of the data that appear in your video. It just shows configuring done, generating done, and build files have been written to… also in sudo make -j $(nproc) it just goes to the next line without making any of the compilations that appear in your video

    When I am going to open the files, they say that the file or directory doesn’t exist. Could you please help me with this problem?

    Thanks a lot

    • Diego

      Hello, Rodrigo. I reinstalled it again and it worked 🙂

      The problem was that in 3rd step after ‘make -j $(nproc)’ I didn’t do ‘sudo make install’

  • Jose L. Rico

    Hey Rodrigo,
    I rerun the whole batch from 0. When testing it I got this error “jose@jose-HP-G61-Notebook-PC:~/opencv/opencv-3.0.0-beta/samples$ ./DisplayImage lena.jpg
    bash: ./DisplayImage: No such file or directory”
    All I did to your syntax was to change the alpha word to beta

    • Did you unzip the provided files inside ‘samples’ directory? Did you check if the ‘DisplayImage’ and ‘lena.jpg’ are inside ‘samples’ directory as well?

      • Jose L. Rico

        Inside samples I have the folders: android, CMakefiles, cpp, data, directx, gpu, java, python2 & tapi. I also see the files cmakecache.txt, cmake_install.cmake. cmakelists.txt and make file.
        Lena.jpg is in the following folder:

        What do you think am I missing? I have tried over 2 years to install opencv in this computer and all attepmts have been unsuccess full

      • To use the ./DisplayImage that I provided, you need to run from within the directory you unzipped it. As you said, DisplayImage isn’t inside this folder, so you can’t do this from this directory.

      • Jose L. Rico

        Hey rodrigo, you were right; however, the problem now is that the picture wont show on screen, but the program is running as it should. Any hint?

      • What happens? Is the window “Display Image” displayed? No errors on the terminal? What you mean by “the program is running as it should”?

      • Jose L. Rico

        No, I finally fixed it. The problem was that there was a typo in the lena syntax. I fixed it and now is working, now I have to sync it with eclipse. Thank you Rodrigo.

      • Great. Enjoy OpenCV!

  • wathmal

    wow, awesome.
    everything works like a charm,, thank you so much!

  • Johan

    Hi I used your script file. When I tried run the first sample, I am getting following error;

    johan@johan-Satellite-L750:~/opencv/opencv-3.0.0-alpha/samples$ sudo cmake .

    CMake Error at CMakeLists.txt:37 (find_package):
    By not providing “FindOpenCV.cmake” in CMAKE_MODULE_PATH this project has
    asked CMake to find a package configuration file provided by “OpenCV”, but
    CMake did not find one.

    Could not find a package configuration file provided by “OpenCV” with any
    of the following names:


    Add the installation prefix of “OpenCV” to CMAKE_PREFIX_PATH or set
    “OpenCV_DIR” to a directory containing one of the above files. If “OpenCV”
    provides a separate development package or SDK, be sure it has been

    — Configuring incomplete, errors occurred!
    See also “/home/johan/opencv/opencv-3.0.0-alpha/samples/CMakeFiles/CMakeOutput.log”.

    • Guenther

      i have the same problem. Ubuntu 14.10, OpenCV 3.0 Beta

      • Try this: export OpenCV_DIR=.
        You must change {opencv_path} to where you have built the opencv.

  • Jared Beekman

    5 days of fighting with distro’s, package managers, and make files…. THANK YOU!

  • Swaroop R

    Thank you so much…….

  • Aubrey Moore

    Thank you for this very useful posting.
    I installed
    opencv-3.0.0-beta. When I try to run the first example I get a message
    saying “Capture from AVI didn’t work”. Any ideas on fixing this?

    Here’s the complete output:

    aubreymoore@aubreymoore-Z2610G:~/opencv-3.0.0-beta/samples/cpp$ ./cpp-example-facedetect lena.jpg

    This program demonstrates the cascade recognizer. Now you can use Haar or LBP features.
    This classifier can recognize many kinds of rigid objects, once the appropriate classifier is trained.
    It’s most known use is for faces.
    ./facedetect [–cascade= this is the primary trained classifier such as frontal face]
    [–nested-cascade[=nested_cascade_path this an optional secondary classifier such as eyes]]

    see facedetect.cmd for one call:

    During execution:
    Hit any key to quit.
    Using OpenCV version 3.0.0-beta

    Processing 1 lena.jpg
    Capture from AVI didn’t work
    init done
    opengl support available
    In image read

    • Aubrey Moore

      SOLVED: Image path is wrong. Should be:
      ./cpp-example-facedetect ../data/lena.jpg

      • You’re probably using OpenCV 3 beta, released in November. They changed the directory structure of samples folder. I’ll make a note about it on the post. Thanks!

  • olf

    I could install opencv3 (the latest beta) thanks to your guide, thanks a lot for that. It seems all libraries are in the coddect place. However, when I try to ceompile the samples nothing happens. I don’t get any error messages and also nothing else. Any idea what the problem could be? I know this question is a bit unspecific, but unfortunately I don’t have anything more to say…

    • Did you try to compile the sample program (2nd test)? Did it work?
      Do you mean nothing happens when you run “sudo cmake .” on the samples directory?

      • olf

        Yes, that is what I meant. However I realised, that all samples were already compiled when I built opencv, so obviously cmake didn’t have anything to do 🙂

      • Glad to hear that!

  • Pingback: OpenCV: Color-spaces and splitting channels » Rodrigo Berriel()

  • Wei qi

    Can you install Matlab on Ubuntu14.04?

    • Jared Beekman

      Matlab can be installed on Ubuntu, but it is really expensive. qtOctave is a suitable alternative, and is in the repositories.

      • Bharat Bhushan

        i don’t think so.

      • grfiv

        I have been using Ubuntu for many releases and I am now at 15.10. Both Matlab and Octave work just fine.

    • Sami Al-Kindi

      of course you can install, just make sure you have the linux version. it should have the .sh file

  • Pingback: Usando OpenCV 3.0.0 com Eclipse » Rodrigo Berriel()