In some OpenCV 3 version there was a change of behavior of cv::waitKey()
in case the delay expired with no key presses, use cv::waitKeyEx() to
rely on the old behavior.
For details see
https://github.com/opencv/opencv/pull/7866#issuecomment-269322846