Mac Ports Cheat Sheet

It’s worth reading the mac ports guide here, but here is my cut down cheat sheet of commands I actually use.

To install a port, e.g opencv

sudo port install opencv

To update ports definition list

sudo port selfupdate

Once, that’s finished you can update the outdated ports (this might take sometime depending on the number of updates)

sudo port upgrade outdated

or you can get a list of the outdated ports

port outdated

and upgraded them manually

sudo port upgrade opencv

This should also upgrade dependencies.

To get a list of installed ports

port installed

To search for a port, eg, PHP you could try

port search php

This will give you hundreds of port that mention PHP in their description. You can filter this, for example

port search --name --glob 'php*'

will return only the ports that start with php.

port info opencv

returns information about the opencv port (the lastest version, so watch out if your ports are out of date). A list of variants can be obtained with

port variants opencv

A port variant can be installed using the syntax:

sudo port install opencv +java

This installs the variant of opencv with java bindings. To see which variant is installed type:

port installed opencv

this lists the variant installed, plus the inactive versions of the library.

If a port fails to build it might be worth cleaning up first by running

sudo port clean opencv

and trying again.

To find out what and where port has installed files run

port contents opencv

To remove a port you use either of

sudo port uninstall opencv
sudo port uninstall --follow-dependents opencv

The second option removes the installed dependents as long as no other port is using them. If you don’t use the latter there will be a number of ports left on your system that you didn’t manually install. These are known as leaves and you can list or remove them with

port echo leaves
sudo port uninstall leaves

You might need to repeat the process since uninstalling leaves may create new leaves!

Port will also leave the outdated ports on your system. To remove them use

sudo port uninstall inactive


Boost and CMake

CMake is wonderful on Linux, the problem on Windows is it can’t always find the library since the user could have installed them anywhere. To get it to find the boost library with the CMake-GUI add a new variable BOOST_ROOT of type Path and set the parameter to the boost home directory.

CMake uses a set of modules to locate common library and you can specify the root of these directly. See the documentation at

OpenCV and QT Creator

Adding openCV to an QtCreator .pro file is easy in Linux simply add

CONFIG += link_pkgconfig
PKGCONFIG += opencv

to the .pro file.

In windows you need to hard code in the directories. To make it cross platform add

INCLUDEPATH += C:\opencv\opencv\build\include
LIBS += -LC:\\opencv\\build\\bin \
libopencv_core2411 \
libopencv_highgui2411 \
libopencv_imgproc2411 \
libopencv_features2d2411 \
libopencv_calib3d2411 \
libopencv_contrib2411 \
libopencv_video2411 \
CONFIG += link_pkgconfig
PKGCONFIG += opencv


but change the windows library names and locations to suit yourself.

Adaptive-particle-filter – Particle filter – Google Project Hosting

The code used for our adaptive particle filter.

adaptive-particle-filter – Particle filter – Google Project Hosting.


For this paper: Hassan, WaqasBangalore Manjunathamurthy, NagachetanBirch, PhilipYoung, Rupert and Chatwin, Chris (2012)Adaptive Sample Count Particle Filter. Computer Vision and Image Understanding, 116 (12). pp. 1208-1222. ISSN 1077-3142

OpenCV and Matlab

I’m experimenting with using OpenCV and Matlab and have come across a problem. Matlab (at least on my Mac) loads its own versions of libraries preferentially. This isn’t normally a problem but if your mex code links against a different version you might get a library conflict. One that I have come across several times is Matlab uses an old version of libtiff (it’s used in imread, imwrite etc) and OpenCV uses a newer version. So when I run an OpenCV mex file, Matlab attempts to load the old version for my OpenCV and the mex file crashes.

My first attempt to solve this was to update the Matlabs version of libtiff – it partially worked. My libraries were fine but it broke imread so it wasn’t acceptable. The solution I found when trying the mexopencv wrapper is to preload the up to date libraries when starting Matlab. The command was

DYLD_INSERT_LIBRARIES=/opt/local/lib/libtiff.5.dylib /Applications/Matlab/ &