making the code compatible with opencv 2.4.7 and higher