Installing opencv

I’ve downloaded opencv but unfortunately I’ve got no idea how to install it. All the pages I found online were only telling me how to download and install it directly from the console, not what to do when you already have it downloaded. Could anybody tell me what to do?

Answer

To Install OpenCV on Ubuntu, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

Ubuntu 12.04 provides a package of OpenCV 2.3.1 that you can easily install by typing:

sudo apt-get install libopencv-dev

If you do not care about having the latest version you could skip the rest.


Install Dependencies

sudo apt-get install build-essential checkinstall cmake pkg-config yasm
sudo apt-get install libtiff4-dev libjpeg-dev libjasper-dev
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
sudo apt-get install python-dev python-numpy
sudo apt-get install libtbb-dev
sudo apt-get install libqt4-dev libgtk2.0-dev

Download OpenCV for Unix to: ~/Downloads

cd Downloads
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.6.1/opencv-2.4.6.1.tar.gz

tar -xvf opencv-2.4.6.1.tar.bz2
cd opencv-2.4.6.1/
mkdir build
cd build

Configure using CMake.

cmake -D WITH_QT=ON -D WITH_XINE=ON -D WITH_OPENGL=ON -D WITH_TBB=ON -D BUILD_EXAMPLES=ON ..

Notice, that by adding the -D WITH_QT=ON, the highgui module will use QT instead of GTK. If you want to go with GTK just remove this. 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:

make

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:

/usr/local/lib

And then configure dynamic linker run-time bindings:

sudo ldconfig

Source:How To Install OpenCV on Ubuntu

Attribution
Source : Link , Question Author : user185184 , Answer Author : pointhi

Leave a Comment