make code compatible with OpenCV 3