here is the most popular link ;)
listing files in a directory
Friday, February 28, 2014
Thursday, February 27, 2014
how to compile opencv on linux (ubuntu)
here is a file (compile.sh) to compile my codes
I have different versions of OpenCv in my system and using 2.4.4 in this case;
#! /bin/bash
PKG_CONFIG_PATH=/usr/local/opencv-2.4.4/lib/pkgconfig:${PKG_CONFIG_PATH}
export PKG_CONFIG_PATH
g++ -o $1 $1.cpp `pkg-config --libs opencv` `pkg-config --cflags opencv`
in order to compile the code type;
./compile.sh <FileNameWithoutExtension>
in order to execute;
./<FileNameWithoutExtension>
I have different versions of OpenCv in my system and using 2.4.4 in this case;
#! /bin/bash
PKG_CONFIG_PATH=/usr/local/opencv-2.4.4/lib/pkgconfig:${PKG_CONFIG_PATH}
export PKG_CONFIG_PATH
g++ -o $1 $1.cpp `pkg-config --libs opencv` `pkg-config --cflags opencv`
in order to compile the code type;
./compile.sh <FileNameWithoutExtension>
in order to execute;
./<FileNameWithoutExtension>
how to install opencv on linux
below find the steps to install opencv on linux (particularly ubuntu)
1. Remove any installed versions of ffmpeg and x264.
sudo apt-get remove ffmpeg x264 libx264-dev
2. update
sudo apt-get update
3. Get all the dependencies for x264 and ffmpeg. If you have them, it will skip it anyways.
sudo apt-get install build-essential checkinstall git cmake libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev texi2html yasm zlib1g-dev
4. Download and install gstreamer. ( gstreamaer and ffmpeg and x264 are important for video processing)
sudo apt-get install libgstreamer0.10-0 libgstreamer0.10-dev gstreamer0.10-tools gstreamer0.10-plugins-base libgstreamer-plugins-base0.10-dev gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly gstreamer0.10-plugins-bad gstreamer0.10-ffmpeg
5. Download and install gtk. If you have it, it will be skipped anyways.
sudo apt-get install libgtk2.0-0 libgtk2.0-dev
6. Download and install libjpeg. If you have it, it will be skipped anyways.
sudo apt-get install libjpeg8 libjpeg8-dev
7. Download and install install x264. ( check if there is any previous version available)
cd ~
mkdir ffmpeg_sources
cd ~/ffmpeg_sources
wget ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20120528-2245-stable.tar.bz2
tar xvf x264-snapshot-20120528-2245-stable.tar.bz2
cd x264-snapshot-20120528-2245-stable
./configure --enable-shared --enable-pic (FOR 64-BIT MACHINE, OTHERWISE REMOVE --enable-pic)
make
sudo make install
8. Download and install install ffmpeg. ( check if there is any previous version available)
cd ~/ffmpeg_sources
wget http://ffmpeg.org/releases/ffmpeg-0.11.1.tar.bz2
tar xvf ffmpeg-0.11.1.tar.bz2
cd ffmpeg-0.11.1
./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 --enable-pic (FOR 64-BIT MACHINE, OTHERWISE REMOVE --enable-pic)
make sudo make install
9. Download and install install a recent version of v4l ( check if there is any previous version available)
cd ~/ffmpeg_sources
wget http://www.linuxtv.org/downloads/v4l-utils/v4l-utils-0.8.8.tar.bz2
tar xvf v4l-utils-0.8.8.tar.bz2
cd v4l-utils-0.8.8
make
sudo make install
10. Download and install OpenCv (check if there is any previous version available)
cd ~
mkdir opencv
cd opencv
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.8/OpenCV-2.4.8.tar.bz2
tar xvf OpenCV-2.4.8.tar.bz2
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local .. (CHECK THE FINAL CMAKE OUTPUT FOR gstreamer, ffmpeg, v4l, and gtk)
make
sudo make install
sudo ldconfig
information is gathered from this and there as well as additional tweaks
http://www.ozbotz.org/opencv-installation/
http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html
http://indranilsinharoy.com/2012/11/01/installing-opencv-on-linux/
1. Remove any installed versions of ffmpeg and x264.
sudo apt-get remove ffmpeg x264 libx264-dev
2. update
sudo apt-get update
3. Get all the dependencies for x264 and ffmpeg. If you have them, it will skip it anyways.
sudo apt-get install build-essential checkinstall git cmake libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev texi2html yasm zlib1g-dev
4. Download and install gstreamer. ( gstreamaer and ffmpeg and x264 are important for video processing)
sudo apt-get install libgstreamer0.10-0 libgstreamer0.10-dev gstreamer0.10-tools gstreamer0.10-plugins-base libgstreamer-plugins-base0.10-dev gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly gstreamer0.10-plugins-bad gstreamer0.10-ffmpeg
5. Download and install gtk. If you have it, it will be skipped anyways.
sudo apt-get install libgtk2.0-0 libgtk2.0-dev
6. Download and install libjpeg. If you have it, it will be skipped anyways.
sudo apt-get install libjpeg8 libjpeg8-dev
7. Download and install install x264. ( check if there is any previous version available)
cd ~
mkdir ffmpeg_sources
cd ~/ffmpeg_sources
wget ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20120528-2245-stable.tar.bz2
tar xvf x264-snapshot-20120528-2245-stable.tar.bz2
cd x264-snapshot-20120528-2245-stable
./configure --enable-shared --enable-pic (FOR 64-BIT MACHINE, OTHERWISE REMOVE --enable-pic)
make
sudo make install
8. Download and install install ffmpeg. ( check if there is any previous version available)
cd ~/ffmpeg_sources
wget http://ffmpeg.org/releases/ffmpeg-0.11.1.tar.bz2
tar xvf ffmpeg-0.11.1.tar.bz2
cd ffmpeg-0.11.1
./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 --enable-pic (FOR 64-BIT MACHINE, OTHERWISE REMOVE --enable-pic)
make sudo make install
9. Download and install install a recent version of v4l ( check if there is any previous version available)
cd ~/ffmpeg_sources
wget http://www.linuxtv.org/downloads/v4l-utils/v4l-utils-0.8.8.tar.bz2
tar xvf v4l-utils-0.8.8.tar.bz2
cd v4l-utils-0.8.8
make
sudo make install
10. Download and install OpenCv (check if there is any previous version available)
cd ~
mkdir opencv
cd opencv
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.8/OpenCV-2.4.8.tar.bz2
tar xvf OpenCV-2.4.8.tar.bz2
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local .. (CHECK THE FINAL CMAKE OUTPUT FOR gstreamer, ffmpeg, v4l, and gtk)
make
sudo make install
sudo ldconfig
information is gathered from this and there as well as additional tweaks
http://www.ozbotz.org/opencv-installation/
http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html
http://indranilsinharoy.com/2012/11/01/installing-opencv-on-linux/
descriptor matcher
if you are looking for matching descriptors or something else,
check out flann_based_matcher.
it also has a function for multiple results (e.g., best two-three or more matches)
check out flann_based_matcher.
it also has a function for multiple results (e.g., best two-three or more matches)
to insert unordered_map
map.insert( make_pair( string, int))
or change the type within "make_pair" depending upon the map
or change the type within "make_pair" depending upon the map
to trim buff after reading line by line with fgets (c++)
buff[ strcspn( buff, "\n")]='\0';
solves the new line at the end of the string (kind of trim() )
solves the new line at the end of the string (kind of trim() )
opencv flann index of a data file with svm-light like --sparse-- data format (e.g., feature_index:feature_value)
to index:
Mat samples; samples.create(rowSize, featSize, CV_32FC1); putFeatures( fileName, featSize, trainSamples); flann::Index flann_index( trainSamples, cv::flann::KMeansIndexParams( 32, 11, cvflann::CENTERS_KMEANSPP, 0.2)); flann_index.save( indexFile);
to read sparse data format:
while( fgets( buff, sizeof(buff), file) != NULL){ first = strtok(buff, " "); second = strtok(NULL, " "); do{ third = strtok(NULL, " "); if( third != NULL){ length = strlen( third); indexOfCol = strcspn ( third, keys); if( indexOfCol < length){ indexStr = strndup(third, indexOfCol); valueStr = strndup(third+indexOfCol+1, length); mat.at( rowIndex, atoi( indexStr)-1) = atof( valueStr); } } }while( third!=NULL); rowIndex++; }
Subscribe to:
Posts (Atom)