make code compatible with opencv3