Fix for (Bug #2789)

see http://code.opencv.org/issues/2789