From 1cb87da0e68e63d54e67d99b30833f2b1ec0fff6 Mon Sep 17 00:00:00 2001 From: Gary Bradski Date: Wed, 1 Dec 2010 01:14:16 +0000 Subject: [PATCH] added docs and minor program changes --- samples/cpp/segment_objects.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/samples/cpp/segment_objects.cpp b/samples/cpp/segment_objects.cpp index 5d472bf0b..c6888e77e 100644 --- a/samples/cpp/segment_objects.cpp +++ b/samples/cpp/segment_objects.cpp @@ -6,6 +6,15 @@ using namespace cv; +void help() +{ + printf("\n" + "This program demonstrated a simple method of connected components clean up of background subtraction\n" + "When the program starts, it begins learning the background. You can toggle background learning on and off\n" + "by hitting the space bar.\n" + "Call\n" + "./segment_objects [video file, else it reads camera 0]\n\n"); +} void refineSegments(const Mat& img, Mat& mask, Mat& dst) { @@ -52,6 +61,8 @@ int main(int argc, char** argv) VideoCapture cap; bool update_bg_model = true; + help(); + if( argc < 2 ) cap.open(0); else @@ -59,7 +70,7 @@ int main(int argc, char** argv) if( !cap.isOpened() ) { - printf("can not open camera or video file\n"); + printf("\nCan not open camera or video file\n"); return -1; } @@ -93,7 +104,10 @@ int main(int argc, char** argv) if( keycode == 27 ) break; if( keycode == ' ' ) + { update_bg_model = !update_bg_model; + printf("Learn background is in state = %d\n",update_bg_model); + } } return 0;