Ported to opencv