Modified openCV code