Get the code work with OpenCV3

Due to the new release of OpenCV3, some interface flags have been changed.
With this code improvement, the issue is fixed.