Pre-compiled: If it works, do this... It prolly won't, but it's worth a shot.
sudo apt-get install libopencv-dev
From Source: as per https://ariandy1.wordpress.com/2013/02/13/raspberry-pi-rasbian-opencv/
sudo apt-get install build-essential cmake pkg-config
sudo apt-get -y install build-essential sudo apt-get -y install cmake sudo apt-get -y install pkg-config sudo apt-get -y install libpng12-0 libpng12-dev libpng++-dev libpng3 sudo apt-get -y install libpnglite-dev libpngwriter0-dev libpngwriter0c2 sudo apt-get -y install zlib1g-dbg zlib1g zlib1g-dev sudo apt-get -y install libjasper-dev libjasper-runtime libjasper1 sudo apt-get -y install pngtools libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools sudo apt-get -y install libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-prog sudo apt-get -y install libavcodec53 libavcodec-dev libavformat53 libavformat-dev sudo apt-get -y install libavutil51 libavutil-dev libswscale2 libswscale-dev sudo apt-get -y install libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev sudo apt-get -y install libxine1-ffmpeg libxine-dev libxine1-bin sudo apt-get -y install libunicap2 libunicap2-dev sudo apt-get -y install libdc1394-22-dev libdc1394-22 libdc1394-utils sudo apt-get -y install swig sudo apt-get -y install python-numpy sudo apt-get -y install libpython2.6 python-dev python2.6-dev sudo apt-get -y install libjpeg-progs libjpeg-dev sudo apt-get -y install libgstreamer-plugins-base0.10-dev sudo apt-get -y install libqt4-dev libgtk2.0-dev
sudo apt-get remove x264 x264-dev 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 make sudo make install cd ..
sudo apt-get remove ffmpeg wget http://ffmpeg.org/releases/ffmpeg-0.11.1.tar.bz2 echo "Installing ffmpeg" 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 make sudo make install cd ..
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 cd ..
tar -xjvf OpenCV-version.tar.bz2 rm OpenCV-version.tar.bz2 cd OpenCV-version/ mkdir build cd build/
See also: