Ported to use with OPENCV