2. First we need to install necessary dev files. A lot of the image format libraries are not necessary but I'm installing them anyway. You can see what's optional and what's not here.
Code: Select all
aptitude install libpng++-dev libjpeg62-dev libtiff4-dev libjasper-dev \
libavcodec-dev cmake subversion gir1.0-gtk-2.0 libavformat-dev \
libswscale-dev libdc1394-22-dev libv4l-dev libgstreamer0.10-dev \
libgtk2.0-dev pkg-config
NB: the official linux guide has an old directory. I will update it after the holidays.
Code: Select all
svn co https://code.ros.org/svn/opencv/trunk/opencv
Code: Select all
mkdir bin
cd bin
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ../opencv/
sudo make install
sudo ldconfig -v
Code: Select all
g++ `pkg-config --cflags --libs opencv` program1.cc -o program1
Code: Select all
#include <highgui.h>
int main(int argc, char* argv[])
{
IplImage* img = cvLoadImage( argv[1] );
cvNamedWindow( "Example1", 0 );
cvShowImage( "Example1", img );
cvWaitKey(-1);
cvReleaseImage( &img );
cvDestroyWindow( "Example1" );
return 0;
}