diff --git a/modules/text/src/ocr_hmm_decoder.cpp b/modules/text/src/ocr_hmm_decoder.cpp index cb635aeff..cb4514e66 100644 --- a/modules/text/src/ocr_hmm_decoder.cpp +++ b/modules/text/src/ocr_hmm_decoder.cpp @@ -444,12 +444,14 @@ void OCRHMMClassifierKNN::eval( InputArray _mask, vector& out_class, vector if (tmp.cols>tmp.rows) { int height = image_width*tmp.rows/tmp.cols; + if(height == 0) height = 1; resize(tmp,tmp,Size(image_width,height)); tmp.copyTo(mask(Rect(0,(image_height-height)/2,image_width,height))); } else { int width = image_height*tmp.cols/tmp.rows; + if(width == 0) width = 1; resize(tmp,tmp,Size(width,image_height)); tmp.copyTo(mask(Rect((image_width-width)/2,0,width,image_height))); }