Commit 9db93d77 authored by Vitaly Tuzov's avatar Vitaly Tuzov

Fix for MSER::detectRegions crash on images with either dimension less than 3

parent 44bda8fb
...@@ -355,7 +355,7 @@ public: ...@@ -355,7 +355,7 @@ public:
/** @brief Detect %MSER regions /** @brief Detect %MSER regions
@param image input image (8UC1, 8UC3 or 8UC4) @param image input image (8UC1, 8UC3 or 8UC4, must be greater or equal than 3x3)
@param msers resulting list of point sets @param msers resulting list of point sets
@param bboxes resulting bounding boxes @param bboxes resulting bounding boxes
*/ */
......
...@@ -1020,12 +1020,11 @@ extractMSER_8uC3( const Mat& src, ...@@ -1020,12 +1020,11 @@ extractMSER_8uC3( const Mat& src,
void MSER_Impl::detectRegions( InputArray _src, vector<vector<Point> >& msers, vector<Rect>& bboxes ) void MSER_Impl::detectRegions( InputArray _src, vector<vector<Point> >& msers, vector<Rect>& bboxes )
{ {
Mat src = _src.getMat(); Mat src = _src.getMat();
size_t npix = src.total();
msers.clear(); msers.clear();
bboxes.clear(); bboxes.clear();
if( npix == 0 ) if( src.rows < 3 || src.cols < 3 )
return; return;
Size size = src.size(); Size size = src.size();
......
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