fixes http://code.opencv.org/issues/3367