Adds CodeBook background segmentation method

This is an implementation of http://www.umiacs.umd.edu/~knkim/paper/Kim-RTI2005-FinalPublished.pdf. Took something from the legacy codebook code too.
please, remove this change; we now handle Ptr&lt;&gt; in Python wrappers automatically