Saturday, November 13, 2010

OpenCV - link libraries and compile

#the source directory would change depending on where you install it

#output errors while compiling are very useful to debug
export LD_LIBRARY_PATH=/usr/src/opencv/release/lib/:$LD_LIBRARY_PATH
ldconfig
PKG_CONFIG_PATH=/usr/src/lib/pkgconfig:${PKG_CONFIG_PATH}
export PKG_CONFIG_PATH
ldconfig

#some examples and guidelines here
linuxconfig.org/introduction-to-computer-vision-with-opencv-on-linux

#compiling
g++ `pkg-config opencv --cflags --libs` example21.cpp -o example21

Friday, November 12, 2010

Building OpenCV

#lets install some requirements
#some of them comes from
#http://opencv.willowgarage.com/wiki/InstallGuide%20:%20Debian

sudo apt-get install pkgconfig
sudo apt-get install build-essential
sudo apt-get install cmake
sudo apt-get install libgtk2.0-dev libavcodec-dev \
libavformat-dev libjpeg62-dev libtiff4-dev
sudo apt-get install libpngwriter0c2
sudo apt-get install zlib1g-dbg zlib1g zlib1g-dev
sudo apt-get install libjasper-dev libjasper-runtime libjasper1
sudo apt-get install pngtools libtiff4-dev libtiff4 libtiffxx0c2
sudo apt-get install libtiff-tools
sudo apt-get install libavcodec-dev libavcodec52
sudo apt-get install libgstreamer0.10-0-dbg libgstreamer0.10-0
sudo apt-get install libgstreamer0.10-dev
sudo apt-get install libxine1-ffmpeg libxine-dev libxine1-bin
sudo apt-get install libunicap2 libunicap2-dev
sudo apt-get install libdc1394-22-dev libdc1394-22 libdc1394-utils
sudo apt-get install swig
sudo apt-get install libv4l-0 libv4l-dev
sudo apt-get install libpython2.6 python-dev python2.6-dev
sudo apt-get install subversion
sudo apt-get install yasm

#feel free to work under /usr/src/ or /usr/local/src ..
#build ffmpeg
sudo svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
./configure --enable-shared
make
sudo make install

#build opencv
sudo svn checkout https://code.ros.org/svn/opencv/trunk/opencv
cd /usr/src/opencv
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/src \
-D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON /usr/src/opencv/
make
sudo make install

#to make python work with opencv it is needed
mv /usr/src/lib/python2.6/site-packages/cv.so \
/usr/local/lib/python2.6/dist-packages/
#to test that it can read the library
# python2.6
>>> import cv
#it should work that way
#IPP librarys can be installed with license