Last active
December 16, 2015 14:28
-
-
Save samgooi4189/5448635 to your computer and use it in GitHub Desktop.
OpenCV 2.4 for linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
THIS TUTORIAL WORKS FOR UBUNTU 12.04 | |
tar xvf OpenCV-2.4.2.tar.bz2 | |
cd OpenCV-2.4.2/ | |
mkdir build | |
cd build | |
To install OpenCV 2.4.2 or 2.4.3 on the Ubuntu 12.04 operating system, first install a developer environment to build OpenCV. | |
sudo apt-get -y install build-essential cmake pkg-config | |
Install Image I/O libraries | |
sudo apt-get -y install libjpeg62-dev | |
sudo apt-get -y install libtiff4-dev libjasper-dev | |
Install the GTK dev library | |
sudo apt-get -y install libgtk2.0-dev libgtkglext1 libgtkglext1-dev | |
Install Video I/O libraries | |
sudo apt-get -y install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libavcodec-dev libavformat-dev libswscale-dev | |
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_OPENGL=ON .. | |
make | |
sudo make install | |
restart | |
configure Eclipse: | |
Create an C++ project | |
right click the project>>properties>>C/C++ Build>>Settings>>GCC C++ Compiler>>include | |
/usr/local/opencv | |
in terminal, to make sure: | |
pkg-config --cflags opencv | |
GCC C++ Linker>>Libraries to include | |
/usr/local/opencv === in library search path | |
in terminal, pkg-config --lib opencv == to see how many libraries | |
include: === in libraries | |
opencv_core | |
opencv_imgproc | |
opencv_highgui | |
opencv_ml | |
opencv_video | |
opencv_features2d | |
opencv_calib3d | |
opencv_objdetect | |
opencv_contrib | |
opencv_legacy | |
opencv_flann | |
Write your opencv program, compile! | |
Configure Linux. | |
Tell linux where the shared libraries for OpenCV are located by entering the following shell command: | |
export LD_LIBRARY_PATH=/usr/local/lib | |
add the command to your .bashrc file so that you don’t have to enter every time your start a new terminal. | |
Alternatively, you can configure the system wide library search path. Using your favorite editor, add a single line containing the text /usr/local/lib to the end of a file named /etc/ld.so.conf.d/opencv.conf. In the standard Ubuntu install, the opencv.conf file does not exist; you need to create it. Using vi, for example, enter the following commands: | |
sudo vi /etc/ld.so.conf.d/opencv.conf | |
G | |
o | |
/usr/local/lib | |
<Esc> | |
:wq! | |
After editing the opencv.conf file, enter the following command: | |
sudo ldconfig /etc/ld.so.conf | |
Using your favorite editor, add the following two lines to the end of /etc/bash.bashrc: | |
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig | |
export PKG_CONFIG_PATH | |
After completing the previous steps, your system should be ready to compile code that uses the OpenCV libraries. | |
The following example shows one way to compile code for OpenCV: | |
g++ `pkg-config opencv --cflags` my_example.cpp -o my_example `pkg-config opencv --libs` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment