Fix compilation and runtime errors when building with OpenCV 3.0