update help corresponding single format and update some samples through using CommandLineParser class

This commit is contained in:
Kirill Kornyakov 2011-05-29 10:01:01 +00:00
parent 2f3b75c841
commit 534ac83b8d
10 changed files with 73 additions and 63 deletions

View File

@ -329,9 +329,9 @@ void help()
"which can be found in contrib.cpp \n"
"Usage: \n"
"./adaptiveskindetector [--fileMask]=<path to file, which are used in mask \n"
" [--firstFrame]=<first frame number \n"
" [--lastFrame]=<last frame number> \n"
" if at least one parameter doesn't specified, it will try to use default webcam \n"
" [--firstFrame]=<first frame number \n"
" [--lastFrame]=<last frame number> \n"
"if at least one parameter doesn't specified, it will try to use default webcam \n"
"Expample: \n"
" --fileMask = /home/user_home_directory/work/opencv/samples/c/temp_%%05d.jpg --firstFrame=0 --lastFrame=1000 \n");
}

View File

@ -44,7 +44,7 @@ void help(void)
"Originally from the book: Learning OpenCV by O'Reilly press\n"
"\nUsage:\n"
"./bgfg_codebook [--nframes]=<frames number, 300 as default> \n"
" [--input]=<movie filename or camera index, zero camera index as default>\n"
" [--input]=<movie filename or camera index, zero camera index as default>\n"
"***Keep the focus on the video windows, NOT the consol***\n\n"
"INTERACTIVE PARAMETERS:\n"
"\tESC,q,Q - quit the program\n"

View File

@ -8,7 +8,7 @@ void help()
"functions cvCreateMemStorage() and cvDrawContours().\n"
"It also shows the use of a trackbar to control contour retrieval.\n"
"\n"
"Call:\n"
"Usage :\n"
"./contours\n");
}

View File

@ -22,9 +22,9 @@ void help()
printf( "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"
"Call:\n"
"Usage :\n"
"./find_obj [--object_filename]=<object_filename, box.png as default> \n"
"[--scene_filename]=<scene_filename box_in_scene.png as default>]\n\n"
" [--scene_filename]=<scene_filename box_in_scene.png as default>]\n\n"
);
}

View File

@ -11,14 +11,17 @@ using namespace cv;
void help()
{
cout << "This program shows the use of the Calonder point descriptor classifier"
"SURF is used to detect interest points, Calonder is used to describe/match these points\n"
"Format:" << endl <<
" classifier_file(to write) test_image file_with_train_images_filenames(txt)" <<
" or" << endl <<
" classifier_file(to read) test_image"
"Using OpenCV version %s\n" << CV_VERSION << "\n"
<< endl;
printf("\n This program shows the use of the Calonder point descriptor classifier \n"
"SURF is used to detect interest points, Calonder is used to describe/match these points \n"
"Usage: \n"
"./find_obj_calonder --classifier_file=<classifier file, there is no default classifier file. You should create it at first and when you can use it for test> \n"
" --test_image=<image file for test, lena.jpg as default> \n"
" [--train_container]=<txt file with train images filenames> \n"
"Example: \n"
" --classifier_file=test_classifier --test_image=lena.jpg --train_container=one_way_train_images.txt \n"
" the test_classifier is created here using --train_container and tested witn --test_image at the end \n"
" --classifier_file=test_classifier --test_image=lena.jpg \n"
" the test classifier is tested here using lena.jpg \n");
}
/*
* Generates random perspective transform of image
@ -144,18 +147,27 @@ void testCalonderClassifier( const string& classifierFilename, const string& img
waitKey();
}
int main( int argc, char **argv )
int main( int argc, const char **argv )
{
if( argc != 4 && argc != 3 )
help();
CommandLineParser parser(argc, argv);
string classifierFileName = parser.get<string>("classifier_file");
string testImageFileName = parser.get<string>("test_image", "lena.jpg");
string trainContainerFileName = parser.get<string>("train_container");
if( classifierFileName.empty())
{
printf("\n Can't find classifier file, please select file for --classifier_file parameter \n");
help();
return -1;
}
if( argc == 4 )
trainCalonderClassifier( argv[1], argv[3] );
if( !trainContainerFileName.empty())
trainCalonderClassifier( classifierFileName.c_str(), trainContainerFileName.c_str() );
testCalonderClassifier( argv[1], argv[2] );
testCalonderClassifier( classifierFileName.c_str(), testImageFileName.c_str() );
return 0;
}

View File

@ -16,7 +16,7 @@ void help()
"descriptor classifier"
"Usage:\n"
"./find_obj_ferns [--object_filename]=<object_filename, box.png as default> \n"
"[--scene_filename]=<scene_filename box_in_scene.png as default>]\n\n");
" [--scene_filename]=<scene_filename box_in_scene.png as default>] \n");
}
int main(int argc, const char** argv)

View File

@ -17,11 +17,10 @@ void help()
{
printf( "This program demonstrated the use of the latentSVM detector.\n"
"It reads in a trained object model and then uses that to detect the object in an image\n"
"Call:\n"
"Usage: \n"
"./latentsvmdetect [--image_filename]=<image_filename, cat.jpg as default> \n"
" [--model_filename] = <model_filename, cat.xml as default> \n"
" [--threads_number] = <number of threads, -1 as default>\n"
" The defaults for image_filename and model_filename are cat.jpg and cat.xml respectively\n"
" Press any key to quit.\n");
}

View File

@ -16,8 +16,8 @@ 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"
"\nCall:\n"
"./mser_sample [--image_filename] <path_and_image_filename, default is 'puzzle.png'>\n\n");
"\n Usage: \n"
"./mser_sample [--image_filename] <path_and_image_filename, default is 'puzzle.png'> \n");
}
static CvScalar colors[] =

View File

@ -18,9 +18,13 @@
void help()
{
printf("\nThis program demonstrates the one way interest point descriptor found in features2d.hpp\n"
"Correspondences are drawn\n");
printf("Format: \n./one_way_sample <path_to_samples> <image1> <image2>\n");
printf("For example: ./one_way_sample --path=../../../opencv/samples/c --first_image=scene_l.bmp --second_image=scene_r.bmp\n");
"Correspondences are drawn\n"
"Usage: \n"
"./one_way_sample [--path]=<path_to_samples, '../../../opencv/samples/c' as default> \n"
" [--first_image]=<first image file, scene_l.bmp as default> \n"
" [--second_image]=<second image file, scene_r.bmp as default>\n"
"For example: \n"
" ./one_way_sample --path=../../../opencv/samples/c --first_image=scene_l.bmp --second_image=scene_r.bmp \n");
}
using namespace cv;

View File

@ -1,21 +1,26 @@
#include "opencv2/core/core.hpp"
#include "opencv2/ml/ml.hpp"
#include "opencv2/core/core_c.h"
#include <stdio.h>
#include <map>
using namespace std;
using namespace cv;
void help()
{
printf(
"\nThis sample demonstrates how to use different decision trees and forests including boosting and random trees:\n"
"CvDTree dtree;\n"
"CvBoost boost;\n"
"CvRTrees rtrees;\n"
"CvERTrees ertrees;\n"
"CvGBTrees gbtrees;\n"
"Call:\n\t./tree_engine [-r <response_column>] [-c] <csv filename>\n"
"where -r <response_column> specified the 0-based index of the response (0 by default)\n"
"-c specifies that the response is categorical (it's ordered by default) and\n"
"<csv filename> is the name of training data file in comma-separated value format\n\n");
printf(
"\nThis sample demonstrates how to use different decision trees and forests including boosting and random trees:\n"
"CvDTree dtree;\n"
"CvBoost boost;\n"
"CvRTrees rtrees;\n"
"CvERTrees ertrees;\n"
"CvGBTrees gbtrees;\n"
"Usage: \n"
" ./tree_engine [--response_column]=<specified the 0-based index of the response, 0 as default> \n"
"[--categorical_response]=<specifies that the response is categorical, 0-false, 1-true, 0 as default> \n"
"[--csv_filename]=<is the name of training data file in comma-separated value format> \n"
);
}
@ -59,34 +64,24 @@ void print_result(float train_err, float test_err, const CvMat* _var_imp)
printf("\n");
}
int main(int argc, char** argv)
int main(int argc, const char** argv)
{
if(argc < 2)
help();
CommandLineParser parser(argc, argv);
string filename = parser.get<string>("csv_filename");
int response_idx = parser.get<int>("response_column", 0);
bool categorical_response = (bool)parser.get<int>("categorical_response", 1);
if(filename.empty())
{
printf("\n Please, select value for --csv_filename key \n");
help();
return 0;
}
const char* filename = 0;
int response_idx = 0;
bool categorical_response = false;
for(int i = 1; i < argc; i++)
{
if(strcmp(argv[i], "-r") == 0)
sscanf(argv[++i], "%d", &response_idx);
else if(strcmp(argv[i], "-c") == 0)
categorical_response = true;
else if(argv[i][0] != '-' )
filename = argv[i];
else
{
printf("Error. Invalid option %s\n", argv[i]);
help();
return -1;
}
return -1;
}
printf("\nReading in %s...\n\n",filename);
printf("\nReading in %s...\n\n",filename.c_str());
CvDTree dtree;
CvBoost boost;
CvRTrees rtrees;
@ -98,7 +93,7 @@ int main(int argc, char** argv)
CvTrainTestSplit spl( 0.5f );
if ( data.read_csv( filename ) == 0)
if ( data.read_csv( filename.c_str() ) == 0)
{
data.set_response_idx( response_idx );
if(categorical_response)