Alright so I have a hard-on for Computer Vision and Machine Learning, and I’m pumped to be getting into it. I’m going to document my experiences learning OpenCV here, and eventually start some cool projects. Please help me out, and provide some feedback!

Download

*NOTE: CMake is now the only method of building OpenCV SVN snapshots.*

*NOTE: Gijs Molenaar has now built OpenCV 2.1 packages for Ubuntu, bless his sweet little soul.*

$ sudo add-apt-repository ppa:gijzelaar/opencv2 $ sudo apt-get update $ sudo apt-get install opencv $ sudo apt-get install libopencv-dev $ sudo apt-get install python-opencv $ sudo apt-get install opencv-doc

Check here for more documentation on installing the Ubuntu packages Ubuntu Installation.

If you want to learn CMake, check my Getting Started with CMake tutorial.

There are a bunch of dependencies that I needed for reading and writing different image and movie formats. I got them all in one fell swoop.

$ sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev cmake libswscale-dev libjasper-dev

There was one of two things I could have done.

Download the stable up to date version of OpenCV from Source Forge. Or my choice, get the cutting edge magic from Willow Garage’s SVN. (I’m so gonna work there one day…)

$ sudo apt-get install subversion $ cd ~/where/you/want/opencv/installed $ svn co https://code.ros.org/svn/opencv/trunk

Installation

So next I just hopped into the opencv folder that I downloaded and as stated above used CMake to build it

$ cd opencv $ cmake .

The ‘ . ‘ arguement sent into cmake told it to look for the CMakeLists.txt file in the current directory. This generated the Makefile for me, so the last step I did was to simply build it.

$ make

Next I had to configure the library, so I opened the config file with the following command

$ sudo vim /etc/ld.so.conf.d/opencv.conf

Since I installed it on Linux I had to add the following line to the bottom of the file, which was empty for me… Not a problem I guess.

/usr/local/lib

Then since I told it where to look for everything at and all the files had been built, I just configured it with the following command

$ sudo ldconfig

Lastly was a little icing on the cake, I put the extension of Intel’s performance primitives package (IPP) into my .bashrc file. I don’t have the optimization primitives by the way, I just thought it’d be nice to have this here in case I somehow become an OpenCV wizard and need them.

$ sudo vim /etc/bash.bashrc

Then add this at the very bottom of the file…

/PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH

HUZZAH! That’s that. Then I just reset my computer and got going on some OpenCV examples! Yay!

Now check the next section on image handling – 2. Basic Image Manipulation.

References

I’m studying from Gary Bradski’s Learning OpenCV