2009年12月8日 星期二

Installing OpenCV 2.0 on Ubuntu 9.10 [轉貼]

November 8th, 2009 by alex
OpenCV is a widely used computer vision library for research and development.
I’ve tried using instructions for installing it from the official manual, but it failed miserably.
It seems that 2.0 code is incompatible with the latest incarnation of ffmpeg. Couple minutes in googling and I had it working.Here is what needs to be done:
Get all the prerequisites:
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev build-dep libswscale-dev swig

Get OpenCV 2.0, and unpack it somewhere
Fix ffmpeg links.
Make sure you are root (sudo -s) and do the following:
mkdir /usr/include/ffmpeg
ln -s /usr/include/libavcodec/avcodec.h /usr/include/ffmpeg/avcodec.h
ln -s /usr/include/libavformat/avformat.h /usr/include/ffmpeg/avformat.h
ln -s /usr/include/libavformat/avio.h /usr/include/ffmpeg/avio.h
ln -s /usr/include/libavutil/avutil.h /usr/include/ffmpeg/avutil.h

Configure OpenCV. In the folder you’ve unpacked it to run:
./configure --prefix=/usr/local/opencv --enable-apps --enable-shared --enable-swscale --enable-gpl --with-swig
sudo ln -s /usr/include/libswscale/swscale.h /usr/include/ffmpeg/swscale.h

Make and install itmake
sudo make install
You could also test it by running make test

Configure your system to look for opencv libraries

echo /usr/local/opencv/lib > /etc/ld.so.conf.d/opencv.conf
Reload the libraries and make sure opencv shows up now
ldconfig -v grep opencv
You may get warnings on unaccessible lib paths, that is ok.
You are looking for a line that says
“/usr/local/opencv/lib”

Set-up pkg-config

echo 'export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opencv/lib/pkgconfig' >> /etc/bash.bashrc
echo 'export PYTHONPATH=/usr/local/opencv/lib/python2.6/site-packages/opencv' >> /etc/bash.bashrc

Restart your terminal to get the new paths
Test by building samplescd

~/Programs/OpenCV-2.0.0/samples/c. build_all.sh

You’re done.

沒有留言:

張貼留言