From 09a7a404781849dc70e762f7533afe083ad8cc6f Mon Sep 17 00:00:00 2001 From: Kirill Kornyakov Date: Fri, 3 Jun 2011 14:53:38 +0000 Subject: [PATCH] The samples were updated corresponding a single standart for --- samples/c/convert_cascade.c | 12 ++++++++++-- samples/c/delaunay.c | 4 ++-- samples/c/fback_c.c | 6 +++--- samples/c/find_obj.cpp | 8 +++++--- samples/c/find_obj_ferns.cpp | 6 ++++-- samples/c/latentsvmdetect.cpp | 6 ++++-- samples/c/morphology.c | 24 ++++++++++++++++-------- samples/c/motempl.c | 4 +++- samples/c/mser_sample.cpp | 4 +++- samples/c/mushroom.cpp | 30 ++++++++++++++++-------------- samples/c/polar_transforms.c | 6 ++++-- samples/c/pyramid_segmentation.c | 28 ++++++++++------------------ 12 files changed, 80 insertions(+), 58 deletions(-) diff --git a/samples/c/convert_cascade.c b/samples/c/convert_cascade.c index a00eb5f017..a112562874 100644 --- a/samples/c/convert_cascade.c +++ b/samples/c/convert_cascade.c @@ -6,8 +6,14 @@ void help() { - printf( "Usage:\n" "" - "./convert_cascade --size=\"x\" input_cascade_path output_cascade_filename\n" ); + printf("\n This sample demonstrates cascade's convertation \n" + "Usage:\n" + "./convert_cascade --size=\"x\" \n" + " input_cascade_path \n" + " output_cascade_filename\n" + "Example: \n" + "./convert_cascade --size=640x480 ../../opencv/data/haarcascades/haarcascade_eye.xml ../../opencv/data/haarcascades/test_cascade.xml \n" + ); } int main( int argc, char** argv ) @@ -17,6 +23,8 @@ int main( int argc, char** argv ) CvHaarClassifierCascade* cascade = 0; CvSize size; + help(); + if( argc != 4 || strncmp( argv[1], size_opt, strlen(size_opt) ) != 0 ) { help(); diff --git a/samples/c/delaunay.c b/samples/c/delaunay.c index 8eed46e91d..896d70d0d4 100644 --- a/samples/c/delaunay.c +++ b/samples/c/delaunay.c @@ -7,8 +7,8 @@ void help() printf("\nThis program demostrates iterative construction of\n" "delaunay triangulation and voronoi tesselation.\n" "It draws a random set of points in an image and then delaunay triangulates them.\n" - "Call:\n" - "./delaunay\n" + "Usage: \n" + "./delaunay \n" "\nThis program builds the traingulation interactively, you may stop this process by\n" "hitting any key.\n"); } diff --git a/samples/c/fback_c.c b/samples/c/fback_c.c index 1be1325075..fb581d1461 100644 --- a/samples/c/fback_c.c +++ b/samples/c/fback_c.c @@ -4,10 +4,10 @@ void help() { printf( - "This program demonstrate dense \"Farneback\n optical flow\n" + "\n This program demonstrate dense \"Farneback\n optical flow\n" "It read from camera 0, and shows how to use and display dense Franeback optical flow\n" - "Call:\n" - "./fback_c\n\n"); + "Usage: \n" + "./fback_c \n"); } void drawOptFlowMap(const CvMat* flow, CvMat* cflowmap, int step, diff --git a/samples/c/find_obj.cpp b/samples/c/find_obj.cpp index c00b5ef9de..6a3eed654b 100644 --- a/samples/c/find_obj.cpp +++ b/samples/c/find_obj.cpp @@ -19,12 +19,14 @@ using namespace cv; void help() { - printf( "This program demonstrated the use of the SURF Detector and Descriptor using\n" + printf( "\n This program demonstrated the use of the SURF Detector and Descriptor using\n" "either FLANN (fast approx nearst neighbor classification) or brute force matching\n" "on planar objects.\n" - "Usage :\n" + "Usage: \n" "./find_obj [--object_filename]= \n" - " [--scene_filename]=]\n\n" + " [--scene_filename]=] \n" + "Example: \n" + "./find_obj --object_filename =box.png --scene_filename = box_in_scene.png \n\n" ); } diff --git a/samples/c/find_obj_ferns.cpp b/samples/c/find_obj_ferns.cpp index 8447903f9a..52c5d26d2f 100644 --- a/samples/c/find_obj_ferns.cpp +++ b/samples/c/find_obj_ferns.cpp @@ -14,9 +14,11 @@ void help() { printf( "This program shows the use of the \"fern\" plannar PlanarObjectDetector point\n" "descriptor classifier" - "Usage:\n" + "Usage: \n" "./find_obj_ferns [--object_filename]= \n" - " [--scene_filename]=] \n"); + " [--scene_filename]=] \n" + "Example: \n" + "./find_obj_ferns --object_filename=box.png --scene_filename=box_in_scene.png \n"); } int main(int argc, const char** argv) diff --git a/samples/c/latentsvmdetect.cpp b/samples/c/latentsvmdetect.cpp index 0097fe7ee6..6144e85dcf 100644 --- a/samples/c/latentsvmdetect.cpp +++ b/samples/c/latentsvmdetect.cpp @@ -19,8 +19,10 @@ void help() "It reads in a trained object model and then uses that to detect the object in an image\n" "Usage: \n" "./latentsvmdetect [--image_filename]= \n" - " [--model_filename] = \n" - " [--threads_number] = \n" + " [--model_filename]= \n" + " [--threads_number]=\n" + "Example: \n" + "./latentsvmdetect --image_filename=cat.jpg --model_filename=cat.xml --threads_number=7 \n" " Press any key to quit.\n"); } diff --git a/samples/c/morphology.c b/samples/c/morphology.c index 327fb8b00d..ffd75473ba 100644 --- a/samples/c/morphology.c +++ b/samples/c/morphology.c @@ -58,23 +58,31 @@ void help() "Morphology operators are built on max (close) and min (open) operators as measured by pixels covered by small structuring elements.\n" "These operators are very efficient.\n" "This program also allows you to play with elliptical, rectangluar and cross structure elements\n" - "Call:\n" + "Usage: \n" "./morphologyc [image_name -- Default baboon.jpg]\n" "\nHot keys: \n" - "\tESC - quit the program\n" - "\tr - use rectangle structuring element\n" - "\te - use elliptic structuring element\n" - "\tc - use cross-shaped structuring element\n" - "\tSPACE - loop through all the options\n" ); + "\tESC - quit the program\n" + "\tr - use rectangle structuring element\n" + "\te - use elliptic structuring element\n" + "\tc - use cross-shaped structuring element\n" + "\tSPACE - loop through all the options\n" ); } int main( int argc, char** argv ) { - char* filename = argc == 2 ? argv[1] : (char*)"baboon.jpg"; + char* filename = 0; + + help(); + + filename = argc == 2 ? argv[1] : (char*)"baboon.jpg"; if( (src = cvLoadImage(filename,1)) == 0 ) + { + printf("Cannot load file image %s\n", filename); + help(); return -1; + } + - help(); dst = cvCloneImage(src); diff --git a/samples/c/motempl.c b/samples/c/motempl.c index ec76696bc1..822a42934f 100644 --- a/samples/c/motempl.c +++ b/samples/c/motempl.c @@ -12,7 +12,7 @@ void help() "of thresholded layers of decaying frame differencing. New movements are stamped on top with floating system\n" "time code and motions too old are thresholded away. This is the 'motion history file'. The program reads from the camera of your choice or from\n" "a file. Gradients of motion history are used to detect direction of motoin etc\n" - "Call:\n" + "Usage :\n" "./motempl [camera number 0-n or file name, default is camera 0]\n" ); } @@ -160,7 +160,9 @@ int main(int argc, char** argv) { IplImage* motion = 0; CvCapture* capture = 0; + help(); + if( argc == 1 || (argc == 2 && strlen(argv[1]) == 1 && isdigit(argv[1][0]))) capture = cvCaptureFromCAM( argc == 2 ? argv[1][0] - '0' : 0 ); else if( argc == 2 ) diff --git a/samples/c/mser_sample.cpp b/samples/c/mser_sample.cpp index c465442991..83b3989fb4 100644 --- a/samples/c/mser_sample.cpp +++ b/samples/c/mser_sample.cpp @@ -17,7 +17,9 @@ void help() printf("\nThis program demonstrates the Maximal Extremal Region interest point detector.\n" "It finds the most stable (in size) dark and white regions as a threshold is increased.\n" "\n Usage: \n" - "./mser_sample [--image_filename] \n"); + "./mser_sample [--image_filename] \n" + "Example: \n" + "./mser_sample --image_filename=puzzle.png \n"); } static CvScalar colors[] = diff --git a/samples/c/mushroom.cpp b/samples/c/mushroom.cpp index 58277fa7ce..67bbaa68b4 100644 --- a/samples/c/mushroom.cpp +++ b/samples/c/mushroom.cpp @@ -5,20 +5,20 @@ void help() { printf("\nThis program demonstrated the use of OpenCV's decision tree function for learning and predicting data\n" - "Call:\n" - "./mushroom \n"); - printf("\n" - "The sample demonstrates how to build a decision tree for classifying mushrooms.\n" - "It uses the sample base agaricus-lepiota.data from UCI Repository, here is the link:\n" - "\n" - "Newman, D.J. & Hettich, S. & Blake, C.L. & Merz, C.J. (1998).\n" - "UCI Repository of machine learning databases\n" - "[http://www.ics.uci.edu/~mlearn/MLRepository.html].\n" - "Irvine, CA: University of California, Department of Information and Computer Science.\n" - "\n" - "// loads the mushroom database, which is a text file, containing\n" - "// one training sample per row, all the input variables and the output variable are categorical,\n" - "// the values are encoded by characters.\n\n"); + "Usage :\n" + "./mushroom \n" + "\n" + "The sample demonstrates how to build a decision tree for classifying mushrooms.\n" + "It uses the sample base agaricus-lepiota.data from UCI Repository, here is the link:\n" + "\n" + "Newman, D.J. & Hettich, S. & Blake, C.L. & Merz, C.J. (1998).\n" + "UCI Repository of machine learning databases\n" + "[http://www.ics.uci.edu/~mlearn/MLRepository.html].\n" + "Irvine, CA: University of California, Department of Information and Computer Science.\n" + "\n" + "// loads the mushroom database, which is a text file, containing\n" + "// one training sample per row, all the input variables and the output variable are categorical,\n" + "// the values are encoded by characters.\n\n"); } int mushroom_read_database( const char* filename, CvMat** data, CvMat** missing, CvMat** responses ) @@ -298,6 +298,8 @@ int main( int argc, char** argv ) CvDTree* dtree; const char* base_path = argc >= 2 ? argv[1] : "agaricus-lepiota.data"; + help(); + if( !mushroom_read_database( base_path, &data, &missing, &responses ) ) { printf( "\nUnable to load the training database\n\n"); diff --git a/samples/c/polar_transforms.c b/samples/c/polar_transforms.c index 4271e3a42c..382e9f8a87 100644 --- a/samples/c/polar_transforms.c +++ b/samples/c/polar_transforms.c @@ -9,7 +9,7 @@ void help() { printf("\nThis program illustrates Linear-Polar and Log-Polar image transforms\n" - "Call:\n" + "Usage :\n" "./polar_transforms [[camera number -- Default 0],[AVI path_filename]]\n\n" ); } @@ -20,15 +20,17 @@ int main( int argc, char** argv ) IplImage* lin_polar_img = 0; IplImage* recovered_img = 0; + help(); + if( argc == 1 || (argc == 2 && strlen(argv[1]) == 1 && isdigit(argv[1][0]))) capture = cvCaptureFromCAM( argc == 2 ? argv[1][0] - '0' : 0 ); else if( argc == 2 ) capture = cvCaptureFromAVI( argv[1] ); - help(); if( !capture ) { fprintf(stderr,"Could not initialize capturing...\n"); fprintf(stderr,"Usage: %s , or \n %s \n",argv[0],argv[0]); + help(); return -1; } diff --git a/samples/c/pyramid_segmentation.c b/samples/c/pyramid_segmentation.c index 5bd84640ba..5244c43cf8 100644 --- a/samples/c/pyramid_segmentation.c +++ b/samples/c/pyramid_segmentation.c @@ -7,7 +7,7 @@ void help() { printf("\nThis program demonstrated color pyramid segmentation cvcvPyrSegmentation() which is controlled\n" "by two trhesholds which can be manipulated by a trackbar. It can take an image file name or defaults to 'fruits.jpg'\n" - "Call:\n" + "Usage :\n" "./pyaramid_segmentation [image_path_filename -- Defaults to fruits.jpg]\n\n" ); } @@ -36,32 +36,24 @@ void ON_SEGMENT(int a) cvPyrSegmentation(image0, image1, storage, &comp, level, threshold1+1, threshold2+1); - /*l_comp = comp->total; - - i = 0; - min_comp.value = cvScalarAll(0); - while(i - fabs(255- cur_comp->value.val[0]) && - fabs(min_comp.value.val[1])> - fabs(cur_comp->value.val[1]) && - fabs(min_comp.value.val[2])> - fabs(cur_comp->value.val[2]) ) - min_comp = *cur_comp; - i++; - }*/ cvShowImage("Segmentation", image1); } int main( int argc, char** argv ) { - char* filename = argc == 2 ? argv[1] : (char*)"fruits.jpg"; + char* filename; + + help(); + + filename = argc == 2 ? argv[1] : (char*)"fruits.jpg"; if( (image[0] = cvLoadImage( filename, 1)) == 0 ) + { + help(); + printf("Cannot load fileimage - %s\n", filename); return -1; + } cvNamedWindow("Source", 0); cvShowImage("Source", image[0]);