The following dependencies are required to use pyblobs library:
sudo apt-get install swig
sudo apt-get install libcv-dev
sudo apt-get install python2.7-dev
sudo apt-get install python-opencv
If you are using Python 2.6, then use
sudo apt-get install python2.6-dev instead.
Getting the pyblobs library
Use svn to grab the source code
svn checkout http://pyblobs.googlecode.com/svn/trunk/ pyblobs-read-only
Patching the files
The code from the trunk as of now uses Python 2.5 (python2.5-dev) and not the best way to link shared objects in the make_swig_shadow.sh file. There is another issue with building the pyblobs library to be used with OpenCV 2.1 in the file BlobExtraction.cpp
Hence, I have created two patch files for the aforementioned files:
Download these to the same directory as the downloaded library (pyblobs-read-only) and then run the following commands in the terminal:
patch make_swig_shadow.sh make_swig_shadow.patch
patch BlobExtraction.cpp BlobExtraction.patch
If you are using Python 2.6, then after patching edit make_swig_shadow.sh and replace any occurennces of python2.7 with python2.6 .
To check your install, go to your Python shell and try the following imports:
>>> from blobs.BlobResult import CBlobResult
>>> from blobs.Blob import CBlob
If all goes well, you shouldn’t see any errors. Now you can work with pyblobs and OpenCV2.1 on Ubuntu 11.10!
That said, to get the example file demo.py working, you might need to modify it a little to use objects and methods from the newer OpenCV Python API. For example, in my programs I replace
from opencv import cv
from opencv import highgui
import cv2.cv as cv to use the new API as cv.MethodName() instead of cv.cvMethodName() or highgui.cvMethodName(). Makes life a lot easier!