Some improved OpenCV 2 vs 3 compatibility