From 56d4f875b4329f6785f0438b9b03bb5f372d5634 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Sat, 4 Dec 2010 15:35:34 +0000 Subject: [PATCH] make watershed demo work correctly --- modules/core/src/drawing.cpp | 2 +- samples/cpp/watershed.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/core/src/drawing.cpp b/modules/core/src/drawing.cpp index 56cac1515a..ada9e7ad90 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 955eaf246f..4e31b19483 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;