Fix bug #4373: Error (Assertion failed in resize) when passing very elongated contours to the recognition module

pull/308/head
lluis 10 years ago
parent 17a947d887
commit 43b5febc63
  1. 2
      modules/text/src/ocr_hmm_decoder.cpp

@ -444,12 +444,14 @@ void OCRHMMClassifierKNN::eval( InputArray _mask, vector<int>& 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)));
}

Loading…
Cancel
Save