bugfix-for-3231

http://code.opencv.org/issues/3231