CONTRAST AND BRIGHTNESS VARIATION OF IMAGES

AUTHORS:ABHISHEK KUMAR ANNAMRAJU,AKASH DEEP SINGH,ADHESH SHRIVASTAVA

Hi Friends,

Lets see how do you change contrast and brightness in opencv

Open a c++ file named contrast.cpp and paste the following code in it

Click once somewhere on the code and press ctrl+A to select whole code.You may not see the whole code so its better to copy the code and paste it in your favourite text editor and then go through it.

**********************CODE STARTS HERE*******************************

#include <cv.h>
#include <highgui.h>
#include <iostream>

using namespace cv;

double alpha; /**< Simple contrast control */
int beta;  /**< Simple brightness control */

int main( int argc, char** argv )
{

Mat image = imread( argv[1] );
Mat new_image = Mat::zeros( image.size(), image.type() );

std::cout<<" Basic Linear Transforms "<<std::endl;
std::cout<<"-------------------------"<<std::endl;
std::cout<<"* Enter the alpha value [1.0-3.0]: ";std::cin>>alpha;
std::cout<<"* Enter the beta value [0-100]: "; std::cin>>beta;

for( int y = 0; y < image.rows; y++ )
{ for( int x = 0; x < image.cols; x++ )
{ for( int c = 0; c < 3; c++ )
{
new_image.at<Vec3b>(y,x)[c] =
saturate_cast<uchar>( alpha*( image.at<Vec3b>(y,x)[c] ) + beta );
}
}
}

namedWindow("Original Image", 1);
namedWindow("New Image", 1);

imshow("Original Image", image);
imshow("New Image", new_image);

return 0;
}

**************************CODE ENDS HERE*******************************

Compilation:

1. chmod +x contrast.cpp
2. g++ -ggdb `pkg-config --cflags opencv` -o `basename contrast.cpp .cpp` contrast.cpp `pkg-config --libs opencv`

Usage:

./contrast IMAGE.EXTENSION CONTRAST_INCREASE_VALUE BRIGHTNESS_ADDING_VALUE

(eg: – ./contrast cat.jpg 2 100)

Advertisements

OPENCV HAAR-TRAINING

AUTHORS:ABHISHEK KUMAR ANNAMRAJU,AKASH DEEP SINGH,ADHESH SHRIVASTAVA

Hi Friends,

Lets have a look at the method to do haar-training in opencv for ubuntu systems

Step1:-GET THE MATERIAL

a)Create a folder named haartraining on the desktop

cd Desktop

mkdir haartraining

cd haartraining

b)Inside the folder create four new folders

mkdir pos

mkdir neg

mkdir samples

mkdir haar

c)Download image database of the object you want to detect,or if you have a set of images with you try cropping them manually to set the region of interest.Copy and paste the positive images in the pos folder and negative images in the neg folder.The following is a database for car.

http://cogcomp.cs.illinois.edu/Data/Car/

d)Create a pearl file named createtrainsamples.pl and copy the following code in it and save in haartraining directory

Note:-The following code has been written by Naotoshi Seo and the copyrights are owned by the same person.I am just using the code for educational purpose.

**************code starts here*********************************

Click once somewhere on the code and press ctrl+A to select whole code.You may not see the whole code so its better to copy the code and paste it in your favourite text editor and then go through it.

#!/usr/bin/perl
use File::Basename;
use strict;
##########################################################################
# Create samples from an image applying distortions repeatedly
# (create many many samples from many images applying distortions)
#
#  perl createtrainsamples.pl <positives.dat> <negatives.dat> <vec_output_dir>
#      [<totalnum = 7000>] [<createsample_command_options = ./createsamples -w 20 -h 20...>]
#  ex) perl createtrainsamples.pl positives.dat negatives.dat samples
#
# Author: Naotoshi Seo
# Date  : 09/12/2008 Add <totalnum> and <createsample_command_options> options
# Date  : 06/02/2007
# Date  : 03/12/2006
#########################################################################
my $cmd = './createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1 -maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 20 -h 20';
my $totalnum = 7000;
my $tmpfile  = 'tmp';

if ($#ARGV < 2) {
print "Usage: perl createtrainsamples.pl\n";
print "  <positives_collection_filename>\n";
print "  <negatives_collection_filename>\n";
print "  <output_dirname>\n";
print "  [<totalnum = " . $totalnum . ">]\n";
print "  [<createsample_command_options = '" . $cmd . "'>]\n";
exit;
}
my $positive  = $ARGV[0];
my $negative  = $ARGV[1];
my $outputdir = $ARGV[2];
$totalnum     = $ARGV[3] if ($#ARGV > 2);
$cmd          = $ARGV[4] if ($#ARGV > 3);

open(POSITIVE, "< $positive");
my @positives = <POSITIVE>;
close(POSITIVE);

open(NEGATIVE, "< $negative");
my @negatives = <NEGATIVE>;
close(NEGATIVE);

# number of generated images from one image so that total will be $totalnum
my $numfloor  = int($totalnum / $#positives);
my $numremain = $totalnum - $numfloor * $#positives;

# Get the directory name of positives
my $first = $positives[0];
my $last  = $positives[$#positives];
while ($first ne $last) {
$first = dirname($first);
$last  = dirname($last);
if ( $first eq "" ) { last; }
}
my $imgdir = $first;
my $imgdirlen = length($first);

for (my $k = 0; $k < $#positives; $k++ ) {
my $img = $positives[$k];
my $num = ($k < $numremain) ? $numfloor + 1 : $numfloor;

# Pick up negative images randomly
my @localnegatives = ();
for (my $i = 0; $i < $num; $i++) {
my $ind = int(rand($#negatives));
push(@localnegatives, $negatives[$ind]);
}
open(TMP, "> $tmpfile");
print TMP @localnegatives;
close(TMP);
#system("cat $tmpfile");

!chomp($img);
my $vec = $outputdir . substr($img, $imgdirlen) . ".vec" ;
print "$cmd -img $img -bg $tmpfile -vec $vec -num $num" . "\n";
system("$cmd -img $img -bg $tmpfile -vec $vec -num $num");
}
unlink($tmpfile);

***********************************code ends here**************************

e)Create a c++ fine named mergevec.cpp,copy the following code and save it in haartraining directory

Note:-The following code has been written by Naotoshi Seo and the copyrights are owned by the same person.I have made a few changes to be able to compile them.I am just using the code for educational purpose.

***********************code starts here*****************************

Click once somewhere on the code and press ctrl+A to select whole code.You may not see the whole code so its better to copy the code and paste it in your favourite text editor and then go through it.

#include <cv.h>
#include <highgui.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#include "cvhaartraining.h"
#include "_cvhaartraining.h" // Load CvVecFile
// Write a vec header into the vec file (located at cvsamples.cpp)
void icvWriteVecHeader( FILE* file, int count, int width, int height );
// Write a sample image into file in the vec format (located at cvsamples.cpp)
void icvWriteVecSample( FILE* file, CvArr* sample );
// Append the body of the input vec to the ouput vec
void icvAppendVec( CvVecFile &in, CvVecFile &out, int *showsamples, int winwidth, int winheight );
// Merge vec files
void icvMergeVecs( char* infoname, const char* outvecname, int showsamples, int width, int height );

// Append the body of the input vec to the ouput vec
void icvAppendVec( CvVecFile &in, CvVecFile &out, int *showsamples, int winwidth, int winheight )
{
CvMat* sample;

if( *showsamples )
{
cvNamedWindow( "Sample", CV_WINDOW_AUTOSIZE );
}
if( !feof( in.input ) )
{
in.last = 0;
in.vector = (short*) cvAlloc( sizeof( *in.vector ) * in.vecsize );
if ( *showsamples )
{
if ( in.vecsize != winheight * winwidth )
{
fprintf( stderr, "ERROR: -show: the size of images inside of vec files does not match with %d x %d, but %d\n", winheight, winwidth, in.vecsize );
exit(1);
}
sample = cvCreateMat( winheight, winwidth, CV_8UC1 );
}
else
{
sample = cvCreateMat( in.vecsize, 1, CV_8UC1 );
}
for( int i = 0; i < in.count; i++ )
{
icvGetHaarTraininDataFromVecCallback( sample, &in );
icvWriteVecSample ( out.input, sample );
if( *showsamples )
{
cvShowImage( "Sample", sample );
if( cvWaitKey( 0 ) == 27 )
{
*showsamples = 0;
}
}
}
cvReleaseMat( &sample );
cvFree( (void**) &in.vector );
}
}

void icvMergeVecs( char* infoname, const char* outvecname, int showsamples, int width, int height )
{
char onevecname[PATH_MAX];
int i = 0;
int filenum = 0;
short tmp;
FILE *info;
CvVecFile outvec;
CvVecFile invec;
int prev_vecsize;

// fopen input and output file
info = fopen( infoname, "r" );
if ( info == NULL )
{
fprintf( stderr, "ERROR: Input file %s does not exist or not readable.\n", infoname );
exit(1);
}
outvec.input = fopen( outvecname, "wb" );
if ( outvec.input == NULL )
{
fprintf( stderr, "ERROR: Output file %s is not writable.\n", outvecname );
exit(1);
}

// Header
rewind( info );
outvec.count = 0;
for ( filenum = 0; ; filenum++ )
{
if ( fscanf( info, "%s", onevecname ) == EOF )
{
break;
}
invec.input = fopen( onevecname, "rb" );
if ( invec.input == NULL )
{
fprintf( stderr, "ERROR: Input file %s does not exist or not readable.\n", onevecname );
exit(1);
}
fread( &invec.count,   sizeof( invec.count )  , 1, invec.input );
fread( &invec.vecsize, sizeof( invec.vecsize ), 1, invec.input );
fread( &tmp, sizeof( tmp ), 1, invec.input );
fread( &tmp, sizeof( tmp ), 1, invec.input );

outvec.count += invec.count;
if( i > 0 &&  invec.vecsize != prev_vecsize )
{
fprintf( stderr, "ERROR: The size of images in %s(%d) is different with the previous vec file(%d).\n", onevecname, invec.vecsize, prev_vecsize );
exit(1);
}
prev_vecsize = invec.vecsize;
fclose( invec.input );
}
outvec.vecsize = invec.vecsize;
icvWriteVecHeader( outvec.input, outvec.count, outvec.vecsize, 1);

// Contents
rewind( info );
outvec.count = 0;
for ( i = 0; i < filenum ; i++ )
{
if (fscanf( info, "%s", onevecname ) == EOF) {
break;
}
invec.input = fopen( onevecname, "rb" );
fread( &invec.count,   sizeof( invec.count )  , 1, invec.input );
fread( &invec.vecsize, sizeof( invec.vecsize ), 1, invec.input );
fread( &tmp, sizeof( tmp ), 1, invec.input );
fread( &tmp, sizeof( tmp ), 1, invec.input );

icvAppendVec( invec, outvec, &showsamples, width, height );
fclose( invec.input );
}
fclose( outvec.input );
}

int main( int argc, char **argv )
{
int i;
char *infoname   = NULL;
char *outvecname = NULL;
int showsamples  = 0;
int width        = 24;
int height       = 24;

if( argc == 1 )
{
printf( "Usage: %s\n  <collection_file_of_vecs>\n"
"  <output_vec_filename>\n"
"  [-show] [-w <sample_width = %d>] [-h <sample_height = %d>]\n",
argv[0], width, height );
return 0;
}
for( i = 1; i < argc; ++i )
{
if( !strcmp( argv[i], "-show" ) )
{
showsamples = 1;
// width = atoi( argv[++i] ); // obsolete -show width height
// height = atoi( argv[++i] );
}
else if( !strcmp( argv[i], "-w" ) )
{
width = atoi( argv[++i] );
}
else if( !strcmp( argv[i], "-h" ) )
{
height = atoi( argv[++i] );
}
else if( argv[i][0] == '-' )
{
fprintf( stderr, "ERROR: The option %s does not exist. n", argv[i] );
exit(1);
}
else if( infoname == NULL )
{
infoname = argv[i];
}
else if( outvecname == NULL )
{
outvecname = argv[i];
}
}
if( infoname == NULL )
{
fprintf( stderr, "ERROR: No input file\n" );
exit(1);
}
if( outvecname == NULL )
{
fprintf( stderr, "ERROR: No output file\n" );
exit(1);
}
icvMergeVecs( infoname, outvecname, showsamples, width, height );
return 0;
}

**************************code ends here********************

f)compiling the mergevec.cpp to get an executable file

copy the following files from your installed opencv folder and save them in haartraining

cvboost.cpp
cvclassifier.h
cvcommon.cpp
_cvcommon.h
cvhaarclassifier.cpp
cvhaartraining.cpp
cvhaartraining.h
_cvhaartraining.h
cvsamples.cpp

open a terminal in the haartraining folder and type

1. chmod +x mergevec.cpp

2. g++ `pkg-config --cflags opencv` -o mergevec mergevec.cpp cvboost.cpp cvcommon.cpp cvsamples.cpp cvhaarclassifier.cpp cvhaartraining.cpp `pkg-config --libs opencv`

Step2:-Starting haartraining

open a terminal and go to the haartraining folder and type

1. find ./neg -iname "*.(EXTENSION OF YOUR IMAGES)" > negatives.txt 

2. find ./pos -iname "*.(EXTENSION OF YOUR IMAGES)" > positives.txt 

3. perl createtrainsamples.pl positives.txt negatives.txt samples 2000
"opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1
-maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 20 -h 20"

Note:-width(-w) and height(-h) should be of the images in pos folder.I assume you would keep every image of same dimensions)

4. find ./samples -name '*.vec' > samples.txt

5.    ./mergevec samples.txt samples.vec

6. opencv_haartraining -data haar -vec samples.vec -bg negatives.txt -nstages 20 -nsplits 2 -minhitrate 0.999 -maxfalsealarm 0.5 -npos 7000 -nneg 3019 -w 20 -h 20 -nonsym -mem 512 -mode ALL

Note:

a)-npos and -nneg must have the number of photos you have in pos and neg folder respectively.
b)choosing minhitrate and maxfalsealarm

For example you have 1000 positive samples. You want your system to detect 900 of them. So desired hitrate = 900/1000 = 0.9. Commonly, put minhitrate = 0.999^number of stages

For example you have 1000 negative samples. Because it’s negative, you don’t want your system to detect them. But your system, because it has error, will detect some of them. Let error be about 490 samples, so false alarm = 490/1000 = 0.49. Commonly,put false alarm  = 0.5^number of stages

Note:

1)The number of negative images must be greater than twice the number of positive images.

2)Try to set npos = 0.9 * number_of_positive_samples and 0.99 as a minHitRate.

3)vec-file has to contain >= (npos + (numStages-1) * (1 – minHitRate) * numPose) + S, where S is a count of samples from vec-file.S is a count of samples from vec-file that can be recognized as background right away.

Step3:-

This is the most important step

KEEP INFINITE PATIENCE TILL THE PROCESS ENDS.FOR A GOOD TRAINING SOMETIMES IT TAKES ABOUT 10 DAYS.YOU COULD TEST THE ABOVE PROCESS BY TAKING FEW IMAGES AND REDUCING THE NUMBER OF STAGES

Note:to speed up the process refer to

http://www.computer-vision-software.com/blog/2009/11/faq-opencv-haartraining/

Thus a xml file will be created in the haar folder which you can use further.

For example,the face detction code in the opencv examples could be used but with change in the xml file name.

A better way of using the xml file is running it through the code I made for object detection using multiple xml file
Refer:https://abhishek4273.wordpress.com/2014/03/16/object-detection-using-multiple-traincascaded-xml-files/

Code and other xml files(do read README.nd):https://github.com/abhi-kumar/CAR-DETECTION.git

This ends up the process

Thank you 🙂

####################CHEERS#########################

See also :- http://blindperception.wordpress.com/

OPENCV READ IMAGE AND VIDEO

AUTHORS:ABHISHEK KUMAR ANNAMRAJU,AKASH DEEP SINGH,ADHESH SHRIVASTAVA

Hi Friends,

Lets look into a way of opening image/video/camera with opencv

Reading an image:-

1)Create a new  c++ file (eg-open_image.cpp )

2)Code(copy the code in the file):-

Click once somewhere on the code and press ctrl+A to select whole code.You may not see the whole code so its better to copy the code and paste it in your favourite text editor and then go through it.


#include &lt;highgui.h&gt;     //main header file

int main( int argc,char** argv)
{
IplImage* img = cvLoadImage(argv[1]);
//IplImage is an old way of reading,Mat can also be used

cvNamedWindow("example" ,CV_WINDOW_AUTOSIZE);
//naming a window to show image

cvShowImage("example,img);
//Tranferring the image read to the window

cvWaitKey(0);
//creating a waitkey to put up a stable window

cvReleaseImage( &amp;img);
cvDestroyWindow("example");
}


3)Compiling and Executing:-
Open a terminal and change the directory to where the file is present and type

a)chmod +x FILENAME.cpp

Note:FILENAME is the name given to the file,use the one you used

b)g++ -ggdb `pkg-config --cflags opencv` -o `basename FILENAME.cpp .cpp` FILENAME.cpp `pkg-config --libs opencv`
c)./FILENAME

Reading a video/camera input:-

1)Create a new  c++ file (eg-open_image.cpp )

2)Code(copy the code in the file):-

#include <highgui.h>

CvCapture* capture = NULL;
int main( int argc, char** argv )
{
cvNamedWindow( "example5", CV_WINDOW_AUTOSIZE );

if(argc == 1)
{
capture = cvCreateCameraCapture(0);
}
else
{
capture = cvCreateFileCapture(argv[1]);
}
assert(capture != NULL);
IplImage* frame;
while(1)
{
frame = cvQueryFrame( capture );
if( !frame ) break;
cvShowImage( "example5", frame );
char c = cvWaitKey(33);
if( c == 27 ) break;
}
cvReleaseCapture( &capture );
cvDestroyWindow( "example5" );
}

3)Compiling and Executing:-
Open a terminal and change the directory to where the file is present and type

a)chmod +x FILENAME.cpp
Note:FILENAME is the name given to the file,use the one you used
b)g++ -ggdb `pkg-config --cflags opencv` -o `basename FILENAME.cpp .cpp` FILENAME.cpp `pkg-config --libs opencv`

c)./FILENAME (for video)

d)./FILENAME _____________ (for video,the video file name goes in the blank,eg:- ./FILENAME video.mkv and the video file should be in same folder of the cpp file otherwise whole path should me mentioned while execution eg:- ./FILENAME /home/USER/Desktop/video.mkv)

Thank you 🙂

See also :- http://blindperception.wordpress.com/

INSTALL OPENCV

Hi Friends

Lets Install Opencv-2.4.6.1 as it has resolved bugs and stable

Step 1:-
Open a new document and paste the following in it

**(The following code has been written by Jayrambhia(Student of Bits-Pilani).I just intend to use the code as an open source  material to provide an educational benefit to others.)

********************TEXT STARTS HERE*****************

arch=$(uname -m)
if [ "$arch" == "i686" -o "$arch" == "i386" -o "$arch" == "i486" -o "$arch" == "i586" ]; then
flag=1
else
flag=0
fi
echo "Installing OpenCV 2.4.6.1"
mkdir OpenCV
cd OpenCV
echo "Removing any pre-installed ffmpeg and x264"
sudo apt-get -y remove ffmpeg x264 libx264-dev
echo "Installing Dependenices"
sudo apt-get -y install libopencv-dev
sudo apt-get -y install build-essential checkinstall cmake pkg-config yasm
sudo apt-get -y install libtiff4-dev libjpeg-dev libjasper-dev
sudo apt-get -y 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 -y install python-dev python-numpy
sudo apt-get -y install libtbb-dev
sudo apt-get -y install libqt4-dev libgtk2.0-dev
sudo apt-get -y install libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev
sudo apt-get -y install x264 v4l-utils ffmpeg
echo "Downloading OpenCV 2.4.6.1"
wget -O OpenCV-2.4.6.1.tar.gz http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.6.1/opencv-2.4.6.1.tar.gz/download
echo "Installing OpenCV 2.4.6.1"
tar -xvf OpenCV-2.4.6.1.tar.gz
cd opencv-2.4.6.1
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
make -j4
sudo make install
sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
echo "OpenCV 2.4.6.1 ready to be used"

*******************TEXT ENDS HERE**************************

b)save the file as opencv.sh on the desktop

Step2:-
Open a terminal and type

a)cd Desktop
b)chmod +x opencv.sh
c)./opencv.sh

wait till u get the message ” OpenCV 2.4.6.1 ready to be used ”

####################CHEERS###########################

Thank you 🙂

See also :- http://blindperception.wordpress.com/

10-STEP PROCESS TO INSTALL PLAYER/STAGE/GAZEBO IN UBUNTU

AUTHORS:ABHISHEK KUMAR ANNAMRAJU,AKASH DEEP SINGH,ADHESH SHRIVASTAVA

Hi Friends

Lets get into installing player project in the ubuntu system in a very easy process of 10 steps.

Note:Please make sure the system has no version of opencv installed,if present make sure to remove it completely from the system libraries.You can install it after this process is complete.Also for  Ubuntu 12.10,13.04 or 13.10 the process remains same,but the library names/versions of dependencies we are going to install may differ.

Let’s get started:-

Step 1:-

Create a directory named src in /home directory

In the terminal,type the following

a)mkdir src
b)cd src

Step 2:-

Download player and stage tar files and store in src
LINKS:
http://sourceforge.net/projects/playerstage/files/Player/3.0.2/player-3.0.2.tar.gz/download
http://sourceforge.net/projects/playerstage/files/Stage/3.2.2/Stage-3.2.2-Source.tar.gz/download

Step 3:-

Install pre-requisites/dependencies

in the terminal,type the following

a)sudo apt-get update
b)sudo apt-get upgrade
c)sudo apt-get install autotools-dev
d)sudo apt-get install build-essential
e)sudo apt-get install cmake
f)sudo apt-get install cpp
g)sudo apt-get install libboost-signals1.46.1
h)sudo apt-get install libboost-signals1.46-dev
i)sudo apt-get install libboost-thread1.46.1
j)sudo apt-get install libboost-thread1.46-dev
k)sudo apt-get install libcv2.3
l)sudo apt-get install libcv-dev
m)sudo apt-get install libgdk-pixbuf2.0-0
n)sudo apt-get install libgdk-pixbuf2.0-dev
o)sudo apt-get install libgnomecanvas2-0
p)sudo apt-get install libgnomecanvas2-dev
q)sudo apt-get install libgsl0-dev
r)sudo apt-get install libgtk2.0-dev
s)sudo apt-get install libjpeg62-dev
t)sudo apt-get install libtool
u)sudo apt-get install libxmu-dev swig
v)sudo apt-get install python2.7-dev
w)sudo apt-get install libcv-dev
x)sudo apt-get install libcvaux-dev
y)sudo apt-get install libhighgui-dev
z)sudo apt-get install freeglut3

a)sudo apt-get install freeglut3-dev
b)sudo apt-get install libfltk1.1
c)sudo apt-get install libfltk1.1-dev
d)sudo apt-get install libltdl7
e)sudo apt-get install libltdl-dev
f)sudo apt-get install libpng12-dev
g)sudo apt-get install libpng12-0

a)sudo apt-get update
b)sudo apt-get upgrade

Step 4:-

Install player-

In the terminal,type the following

a)tar xzvf player-3.0.2.tar.gz
b)cd player-3.0.2
c)mkdir build
d)cd build
e)cmake ../
f)sudo make

*****************************************************************************

NOTE:-Error bugs for make(if errors dont appear in ‘make’,please skip this part)

–error bugs while installation(if no errors skip this part)
1)cmake stopped with errors in timer.cpp
:- add #include <unistd.h> in timer.cpp

2)artoolkitplus error
:- install artoolkitplus
–$ cd Downloads
$ wget https://launchpad.net/artoolkitplus/trunk/2.3.0/+download/ARToolKitPlus-2.3.0.tar.bz2
$ tar xvjf ARToolKitPlus-2.3.0.tar.bz2
$ cd ARToolKitPlus-2.3.0
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install

3)cmake stopped with readlog.cc error
:-make changes in readlog.cc
change line 668  –>  ret = gzseek(this->file,0,SEEK_SET);
TO –>                ret = gzseek((gzFile)this->file,0,SEEK_SET);
change line 714  –>  ret = (gzgets(this->file, this->line, this->line_size) == NULL);
TO –>                ret = (gzgets((gzFile)this->file, this->line, this->line_size) == NULL);

4)assembler message error
:- do “sudo make” instead of “make”

5)link cxx error-(cannot find opencv and other bullshits)(STILL A PROBLEM)

a)changes in .bashrc file of build
$cd
$gksudo gedit ./bashrc
add the following to it
$ export PATH=~/usr/local/bin:$PATH
$ export CPATH=~/usr/local/include:$CPATH
$ export LD_LIBRARY_PATH=~/usr/lib:$LD_LIBRARY_PATH

b)change the CMAKE_CXX_FLAGS variable in /player-3.0.2/build/CMakeCache.txt.
Change the line
CMAKE_CXX_FLAGS:STRING=
To
CMAKE_CXX_FLAGS:STRING=   -lboost_system
c)install all libdc files
d)install libpq-dev libpqxx-dev

****************************END OF ERROR BUGS*******************

g)sudo make

h)sudo make install

i)sudo updatedb

Step 5:-

Open a new terminal and type

a)gksudo gedit ./bashrc

When the file opens,add the following to the end of it

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/USER/src/player-3.0.2/build/libplayercore
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/USER/src/player-3.0.2/build/libplayerinterface
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/USER/src/player-3.0.2/build/libplayercommon
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/USER/src/player-3.0.2/build/
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/USER/src/player-3.0.2/build/client_libs/libplayerc++
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/USER/src/player-3.0.2/build/client_libs/libplayerc
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH
export PATH=$PATH:"/usr/local/lib64"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"/usr/local/lib":"/usr/local/lib64"
export PLAYERPATH="/usr/local/lib":"/usr/local/lib64"
export STAGEPATH="/usr/local/lib":"/usr/local/lib64"

Step 6:-

Checking installation

in the treminal : $ pkg-config –libs playercore
(output: -L/usr/local/lib64 -lplayercore -lpthread -lltdl -ldl -lplayerinterface -lplayercommon)
In the terminal : $ pkg-config –cflags playercore
(output: -I/usr/local/include/player-3.0)

Step 7:-

Install Stage

In the terminal,type the following

a)sudo apt-get update
b)sudo apt-get upgrade
c)tar xzvf Stage-3.2.2-Source.tar.gz
d)cd Stage-3.2.2-Source/
e)mkdir build
f)cd build/
g)cmake ../
h)sudo make

*****************************************************************************************

NOTE:-Error bugs for make(if errors dont appear in ‘make’,please skip this part)

–error bugs while installation(if no errors skip this part)

–error with undefined reference to various libs and functions

In the same terminal,type
a)cd ..
c)sudo gedit CMakeLists.txt

Note:-This CMakeListestxt file will be in the folder player-3.0.2,make sure to do the changes in the correct one if you open a new terminal
change the three lines:

SET (CMAKE_CXX_FLAGS_RELEASE " -O3 -DNDEBUG ${WALL} " CACHE INTERNAL "C Flags for release" FORCE)
SET (CMAKE_CXX_FLAGS_DEBUG " -ggdb ${WALL} " CACHE INTERNAL "C Flags for debug" FORCE)
SET (CMAKE_CXX_FLAGS_PROFILE " -O3 -ggdb -pg ${WALL} " CACHE INTERNAL "C Flags for profile" FORCE)

TO:

SET (CMAKE_CXX_FLAGS_RELEASE " -O3 -DNDEBUG -Wl,--no-as-needed" CACHE INTERNAL "C Flags for release" FORCE)
SET (CMAKE_CXX_FLAGS_DEBUG " -ggdb -Wl,--no-as-needed " CACHE INTERNAL "C Flags for debug" FORCE)
SET (CMAKE_CXX_FLAGS_PROFILE " -O3 -ggdb -pg -Wl,--no-as-needed " CACHE INTERNAL "C Flags for profile" FORCE)

(save and close the file)

********************* END OF ERROR BUGS*******************************

i)cd build

j)sudo make

k)sudo make install

Step 8:-

Testing installation
open a new terminal
a)cd src/Stage-3.2.2-Source/worlds
b)player simple.cfg

Note:

Error:-

player: error while loading shared libraries: libplayerdrivers.so.3.0: cannot open shared object file: No such file or directory.

open a terminal and write:-

export LD_LIBRARY_PATH+=/usr/local/lib64:/usr/local/lib

Step 9:-

Installing gazebo(1.9.1)
open a new terminal

a)sudo sh -c ‘echo “deb http://packages.osrfoundation.org/gazebo/ubuntu precise main” > /etc/apt/sources.list.d/gazebo-latest.list’
b)wget http://packages.osrfoundation.org/gazebo.key -O – | sudo apt-key add –
c)sudo apt-get update
d)sudo apt-get install gazebo

Step 10 :-

Testing gazebo
open a new terminal

a)gazebo
(for the first run it takes time to open the gui,keep patience)

NOTE:-to add models manually to gazebo

open a terminal and type

a)cd ~/.gazebo/models

b)wget -R *index.html*,*.tar.gz –cut-dirs=1 –no-parent -r -x -nH http://gazebosim.org/models/HERE YOU ENTER THE MODEL NAME/

You have now succeeded in installing player/stage/gazebo.

For any further queries please let me know in the blog or mail me at “abhishek4273@gmail.com”.

############CHEERS############

Thank you 🙂

See also :- http://blindperception.wordpress.com/

Robotics And Computer Vision