'ubuntu'에 해당되는 글 1건

  1. 2015.06.15 OpenCV 2.4.9 on Ubuntu 14.04
Linux2015. 6. 15. 21:40


OpenCV 2.4.9 was released on April 2014. See more here.

This is another post in a series of walkthroughs that will hopefully make your life easier to configure, compile, install and test it out.

The dependencies are divided into categories. I have only tested it with GTK.

If you don't need the latest OpenCV then you can easily install version 2.4 using apt:
sudo apt-get install libopencv-dev
If you wanna use the latest version, then follow the steps above:

Install Dependencies

These are libraries and tools required by OpenCV.
sudo apt-get install build-essential checkinstall cmake pkg-config yasm

Image I/O
Libraries for reading and writing various image types. If you do not install then the versions supplied by OpenCV will be used.
sudo apt-get install libtiff4-dev libjpeg-dev libjasper-dev

Video I/O
You need some or all of these packages to add video capturing/encoding/decoding capabilities to the highgui module.
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev

Packages needed to build the Python wrappers.
sudo apt-get install python-dev python-numpy

Other third-party libraries
Install Intel TBB to enable parallel code in OpenCV.
sudo apt-get install libtbb-dev

The default back-end for highgui in Linux is GTK. You can optionally install QT instead of GTK and later enable it in the configuration (see next section) but I haven't tested it with QT on Ubuntu 14.04 yet. 
sudo apt-get install libqt4-dev libgtk2.0-dev

Download Compile & Install

Get a copy of the source code here, extract and create a build directory:
unzip opencv-2.4.9.zip
cd opencv-2.4.9/
mkdir build
cd build
Configure using CMake. You have a lot of options in this step. This is what I use:
If you add -D WITH_QT=ON, the highgui module will use QT instead of GTK. For more information on the options, look at the CMakeLists.txt file. When you are happy with the configuration you have, you can start compiling:
If compilation finishes without errors, you can install by saying:
sudo make install
Finally, make sure that your programs can link to the OpenCV library in run-time by adding the following line at the end of your /etc/ld.so.conf:
And then configure dynamic linker run-time bindings:
sudo ldconfig


An easy way to test that the compilation went well is to use the OpenCV tests and samples. For example, go to opencv-2.4.9/build/bin and run:
You should get the correct version.

If you run other tests notice that some failures come from missing image files. To correctly run these tests or samples you should move the corresponding image files from opencv-2.4.9/samples to OpenCV-2.4.9/build/bin.

For testing that you can compile your own programs and link against the installed OpenCV libraries I have packaged the face detection sample with all the necessary files and a simple Makefile. Download it here, extract and type:
This should compile and run with a test image, so you should see something like this:

'Linux' 카테고리의 다른 글

rc.local에 등록한 시작프로그램이 두번 실행되는 현상  (2) 2015.07.16
OpenCV 2.4.9 on Ubuntu 14.04  (0) 2015.06.15
Posted by 너를위한노래

댓글을 달아 주세요