Thursday, September 20, 2012

Installing OpenCV on Linux Mint (Maya)



Remove any installed versions of ffmpeg and x264.
sudo apt-get remove remove ffmpeg x264 libx264-dev

Install all the dependencies.
sudo apt-get install libopencv-dev
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 the latest version ox x264 from x264 snapshots
tar -xvf x264-snapshot-version.tar.bz2
cd x264-snapshot-version/
If you are using 32 bit Linux
./configure –enable-static
If you’re using 64 bit Linux
./configure –enable-shared –enable-pic
Install it
make
sudo make install
Download the latest version of ffmpeg from ffmpeg Download.
tar -xvf ffmpeg-version.tar.bz2
cd ffmpeg-version/
If you’re using 32 bit Linux
./configure –enable-gpl –enable-libfaac –enable-libmp3lame –enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libtheora –enable-libvorbis –enable-libx264 –enable-libxvid –enable-nonfree –enable-postproc –enable-version3 –enable-x11grab
If you’re using 64 bit Linux or ARM
./configure –enable-gpl –enable-libfaac –enable-libmp3lame –enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libtheora –enable-libvorbis –enable-libx264 –enable-libxvid –enable-nonfree –enable-postproc –enable-version3 –enable-x11grab –enable-shared
Install it
make
sudo make install
Download the latest image of v4l from v4l-utils
tar -xvf v4l-version.tar.bz2
cd v4l-version
make
sudo make install
Download OpenCV 2.4.0
Download OpenCV 2.4.1
Download OpenCV 2.4.2
After downloading OpenCV 2.4.* package, untar it and make.
tar -xvf OpenCV-version.tar.bz2
cd OpenCV-version/
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE ..
Verify that the output of cmake includes the following text:
  • found gstreamer-base-0.10
  • GTK+ 2.x: YES
  • FFMPEG: YES
  • GStreamer: YES
  • V4L/V4L2: Using libv4l
Build and Install OpenCV
make
sudo make install
OpenCV 2.4.* is now installed. Just make sure that all the libraries are linked properly.
Go to samples directory in OpenCV package.
Change directory to C or C++.
You’ll find a script there named build_all.sh.
Execute the script. It will make all the files. select any output file and run it. If it works then you are good to go.
sudo echo “/usr/local/lib” >> /etc/ld.so.conf
sudo ldconfig
Your OpenCV 2.4.* is installed and libraries are properly linked.


Using OpenCV with QtCreator:
  •  Install QtCreator: sudo apt-get install qtcreator
  • To use OpenCV in QtCreator simply add to the .pro file of your project these lines:
INCLUDEPATH += /usr/local/include/opencv
LIBS += -L/usr/local/lib \
-lopencv_core \
-lopencv_imgproc \
-lopencv_highgui \
-lopencv_ml \
-lopencv_video \
-lopencv_features2d \
-lopencv_calib3d \
-lopencv_objdetect \
-lopencv_contrib \
-lopencv_legacy \
-lopencv_flann


Original Post @ link


1 comment:

  1. When i want to link the libraries no script file exist in opencv package!!what shall i do?
    Thanks and regards.

    ReplyDelete