Compatibility with OpenCV < 3.0
More correct C++ template use