From 1f9171d10adcf42a3c656f4b42fc07776320dcdc Mon Sep 17 00:00:00 2001 From: Gary Bradski Date: Wed, 24 Nov 2010 06:03:21 +0000 Subject: [PATCH] find and drawContours doc --- samples/cpp/contours2.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) 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); -- 2.7.4