http://www.cs.uu.nl/docs/vakken/mcv/assignment5/assignment5.html, plain opencv