Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Tuesday, January 5, 2010

OpenCV libcv.so.2.0 error

Sometimes after a fresh install of OpenCV in a fresh install of Linux you may come across the error:

error while loading shared libraries: libcv.so.2.0: cannot open shared object file: No such file or directory


If you do then follow the instructions provided by an OpenCV thread on nabble.com. Click here

Wednesday, August 26, 2009

Ubuntu OpenCV FFMPEG error

If you are in Ubuntu 9.04 and attempting to write a video using OpenCV you may encounter an error such as:

OpenCV Error: Bad argument (codec not found) in CvVideoWriter_FFMPEG::open

The only solution that I have found is to install the following
sudo apt-get install libavcodec-unstripped-52

It seems to remove a bunch of packages but everything I do (reading/writing videos) seems to be working. So proceed with caution on installing this, but it may fix what ails you.

Thursday, August 13, 2009

How to download & compile the latest OpenCV

Once you have your environment set up you will be able to download and compile OpenCV to your Linux environment easily. Some Linux distributions are easier than other to setup. Sabayon is one such distro that comes with many of the necessary packages already installed.

Execute the following commands:
  1. mkdir opencv
  2. svn co https://opencvlibrary.svn.sourceforge.net/svnroot/opencvlibrary/trunk opencv
  3. cd opencv/opencv
  4. mkdir release
  5. cd release
  6. sudo cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ../
Now make sure everything worked and was found. If you get errors you need to fix them now or else you will have issues completing a successful install.

Execute the following:

  1. sudo make
  2. sudo make install

If everything goes as planned OpenCV should compile successfully (100% during the make). If not check your libraries and if all else fails try getting the code from the SVN again.

There it is, you have installed OpenCV from source!

Update #1:
   If you receive the error from cxcorr.hpp indicating that ptrdiff_t does not name a type, please add this line of code to cxcorr.hpp (as indicated by stackoverflow.com):

  1. #include <stddef.h>

Setting up Ubuntu for OpenCV

This article relates how to setup a fresh Ubuntu (9.04 - Jaunty Jackalope) so you can download the latest OpenCV from the repository and then compile it from scratch. Downloading and compiling will be a separate article.

First install some packages using the following commands:
sudo apt-get install build-essential
sudo apt-get install cmake
sudo apt-get install mplayer
sudo apt-get install subversion
sudo apt-get install ffmpeg
sudo apt-get install swig
sudo apt-get install python-all
sudo apt-get install python-all-dev
Second install some libraries using the following commands:
sudo apt-get install libxine1
sudo apt-get install libfftw3-3
sudo apt-get install libfftw3-3-dev
sudo apt-get install libfftw3-dev
sudo apt-get install libvorbis-dev
sudo apt-get install libavcodec-dev
sudo apt-get install libavdevice-dev
sudo apt-get install libavfilter-dev
sudo apt-get install libavformat-dev
sudo apt-get install libavutil-dev
sudo apt-get install libmad0
sudo apt-get install libmad0-dev (maybe not necessary)
sudo apt-get install libpostproc-dev
sudo apt-get install libswscale-dev
sudo apt-get install libxine1-ffmpeg
sudo apt-get install libjasper-dev
sudo apt-get install libtiff4-dev
sudo apt-get install libv4l-dev
sudo apt-get install libslang2-dev
sudo apt-get install libxine-dev
sudo apt-get install libdc1394-22-dev
sudo apt-get install libgstreamer0.10-dev
sudo apt-get install libgtk2.0-dev
Now go into Add/Remove Programs
  1. Search for java runtime
  2. Install Sun Java 6 Runtime
*Note: You will want to select All available applications under Show:
Now install unicap

Follow the directions here, then run the following commands:
sudo apt-get install libunicap2
sudo apt-get install libunicap-dev
sudo apt-get install libucil2
sudo apt-get install libucil-dev
sudo apt-get install libunicapgtk2
sudo apt-get install libunicapgtk-dev

* You can also dowloand the tar.gz and compile and make that by hand

* If you are having trouble writing to files with OpenCV after you have installed all the above, please read this link for the fix.