Installing OpenCV on Ubuntu was painful for me in the past. There are lots of dependencies to be sorted out first and there’s no comprehensive installation tutorial shipped with the OpenCV distribution. This script has done a great job assembling all necessary “apt-get-install’s” into an executable script. Some personal notes about this:
It seems to me " sudo apt-get install libopencv-dev" for dependencies is not necessary - this will be superseded by the subsequent installation of opencv from source. At the end of the scripting installation, the package seems to be in some cache place and be not in effect:
It seems " sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev" is also unnecessary. These libraries are to be provided by the next fresh installation of ffmpeg follows. Checking their location seems to also confirm my guess:
About version of ffmpeg: ffmepg is under active development as always. The choice of its version is sometimes tricky, especially in running together with OpenCV. I remember the 1.x series was not compatible with OpenCV 2.3 in my previous trial (compilation errors were thrown due to some problem with ffmpeg libraries). The current 2.4.3 version seems to be at least fine with ffmpeg 0.11.2 in compilation.
[Update] From test by Mr. Alok Singh Mahor (comments in the original post), installing Ubuntu package “libopencv-dev” would already get things work, though the linking order with g++ has to be taken care of as discussed (also comments in the original post and here) . Of course, it’s not bad idea to install from source that always guarantees to bring in the newest feature of actively developed OpenCV. [Dec 28 2012 / Oct 30 2013]