diff --git a/modules/features2d/include/opencv2/features2d.hpp b/modules/features2d/include/opencv2/features2d.hpp index 32fdabd8a4..4d362923ce 100644 --- a/modules/features2d/include/opencv2/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d.hpp @@ -355,7 +355,7 @@ public: /** @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 bboxes resulting bounding boxes */ diff --git a/modules/features2d/src/mser.cpp b/modules/features2d/src/mser.cpp index 1143addc12..4f2cab1dc0 100644 --- a/modules/features2d/src/mser.cpp +++ b/modules/features2d/src/mser.cpp @@ -1020,13 +1020,12 @@ extractMSER_8uC3( const Mat& src, void MSER_Impl::detectRegions( InputArray _src, vector >& msers, vector& bboxes ) { Mat src = _src.getMat(); - size_t npix = src.total(); msers.clear(); bboxes.clear(); - if( npix == 0 ) - return; + if( src.rows < 3 || src.cols < 3 ) + CV_Error(Error::StsBadArg, "Input image is too small. Expected at least 3x3"); Size size = src.size();