Commit 43b5febc authored by lluis's avatar lluis

Fix bug #4373: Error (Assertion failed in resize) when passing very elongated…

Fix bug #4373: Error (Assertion failed in resize) when passing very elongated contours to the recognition module
parent 17a947d8
...@@ -444,12 +444,14 @@ void OCRHMMClassifierKNN::eval( InputArray _mask, vector<int>& out_class, vector ...@@ -444,12 +444,14 @@ void OCRHMMClassifierKNN::eval( InputArray _mask, vector<int>& out_class, vector
if (tmp.cols>tmp.rows) if (tmp.cols>tmp.rows)
{ {
int height = image_width*tmp.rows/tmp.cols; int height = image_width*tmp.rows/tmp.cols;
if(height == 0) height = 1;
resize(tmp,tmp,Size(image_width,height)); resize(tmp,tmp,Size(image_width,height));
tmp.copyTo(mask(Rect(0,(image_height-height)/2,image_width,height))); tmp.copyTo(mask(Rect(0,(image_height-height)/2,image_width,height)));
} }
else else
{ {
int width = image_height*tmp.cols/tmp.rows; int width = image_height*tmp.cols/tmp.rows;
if(width == 0) width = 1;
resize(tmp,tmp,Size(width,image_height)); resize(tmp,tmp,Size(width,image_height));
tmp.copyTo(mask(Rect((image_width-width)/2,0,width,image_height))); tmp.copyTo(mask(Rect((image_width-width)/2,0,width,image_height)));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment