Update code to work with OpenCV 2