From: Gary Bradski Date: Wed, 24 Nov 2010 06:03:21 +0000 (+0000) Subject: find and drawContours doc X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~8345 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1f9171d10adcf42a3c656f4b42fc07776320dcdc;p=platform%2Fupstream%2Fopencv.git find and drawContours doc --- diff --git a/samples/cpp/contours2.cpp b/samples/cpp/contours2.cpp index 640ed97..1d5806b 100644 --- a/samples/cpp/contours2.cpp +++ b/samples/cpp/contours2.cpp @@ -1,9 +1,21 @@ #include "cv.h" #include "highgui.h" #include +#include using namespace cv; +void help() +{ + cout + << "This program illustrates the use of findContours and drawContours\n" + << "The original image is put up along with the image of drawn contours\n" + << "Usage:\n" + << "./contours2\n" + << "\nA trackbar is put up which controls the contour level from -3 to 3\n" + << endl; +} + const int w = 500; int levels = 3; @@ -20,10 +32,15 @@ void on_trackbar(int, void*) imshow("contours", cnt_img); } -int main( int, char** ) +int main( int argc, char** argv) { Mat img = Mat::zeros(w, w, CV_8UC1); - + if(argc > 1) + { + help(); + return -1; + } + //Draw 6 faces for( int i = 0; i < 6; i++ ) { int dx = (i%2)*250 - 30; @@ -55,10 +72,10 @@ int main( int, char** ) ellipse( img, Point(dx+27, dy+100), Size(20,35), 0, 0, 360, white, -1, 8, 0 ); ellipse( img, Point(dx+273, dy+100), Size(20,35), 0, 0, 360, white, -1, 8, 0 ); } - + //show the faces namedWindow( "image", 1 ); imshow( "image", img ); - + //Extract the contours so that vector > contours0; findContours( img, contours0, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE);