diff --git a/modules/core/src/drawing.cpp b/modules/core/src/drawing.cpp index 56cac1515..ada9e7ad9 100644 --- a/modules/core/src/drawing.cpp +++ b/modules/core/src/drawing.cpp @@ -2033,7 +2033,7 @@ cvDrawContours( void* _img, CvSeq* contour, scalarToRawData( externalColor, ext_buf, img.type(), 0 ); scalarToRawData( holeColor, hole_buf, img.type(), 0 ); - maxLevel = MAX(maxLevel, INT_MIN-2); + maxLevel = MAX(maxLevel, INT_MIN+2); maxLevel = MIN(maxLevel, INT_MAX-1); if( maxLevel < 0 ) diff --git a/samples/cpp/watershed.cpp b/samples/cpp/watershed.cpp index 955eaf246..4e31b1948 100644 --- a/samples/cpp/watershed.cpp +++ b/samples/cpp/watershed.cpp @@ -86,6 +86,8 @@ int main( int argc, char** argv ) findContours(markerMask, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE); + if( contours.empty() ) + continue; Mat markers(markerMask.size(), CV_32S); markers = Scalar::all(0); int idx = 0;