update help corresponding single format and update some samples through using CommandLineParser class
This commit is contained in:
parent
2f3b75c841
commit
534ac83b8d
@ -331,7 +331,7 @@ void help()
|
|||||||
"./adaptiveskindetector [--fileMask]=<path to file, which are used in mask \n"
|
"./adaptiveskindetector [--fileMask]=<path to file, which are used in mask \n"
|
||||||
" [--firstFrame]=<first frame number \n"
|
" [--firstFrame]=<first frame number \n"
|
||||||
" [--lastFrame]=<last frame number> \n"
|
" [--lastFrame]=<last frame number> \n"
|
||||||
" if at least one parameter doesn't specified, it will try to use default webcam \n"
|
"if at least one parameter doesn't specified, it will try to use default webcam \n"
|
||||||
"Expample: \n"
|
"Expample: \n"
|
||||||
" --fileMask = /home/user_home_directory/work/opencv/samples/c/temp_%%05d.jpg --firstFrame=0 --lastFrame=1000 \n");
|
" --fileMask = /home/user_home_directory/work/opencv/samples/c/temp_%%05d.jpg --firstFrame=0 --lastFrame=1000 \n");
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ void help()
|
|||||||
"functions cvCreateMemStorage() and cvDrawContours().\n"
|
"functions cvCreateMemStorage() and cvDrawContours().\n"
|
||||||
"It also shows the use of a trackbar to control contour retrieval.\n"
|
"It also shows the use of a trackbar to control contour retrieval.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Call:\n"
|
"Usage :\n"
|
||||||
"./contours\n");
|
"./contours\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,9 +22,9 @@ void help()
|
|||||||
printf( "This program demonstrated the use of the SURF Detector and Descriptor using\n"
|
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"
|
"either FLANN (fast approx nearst neighbor classification) or brute force matching\n"
|
||||||
"on planar objects.\n"
|
"on planar objects.\n"
|
||||||
"Call:\n"
|
"Usage :\n"
|
||||||
"./find_obj [--object_filename]=<object_filename, box.png as default> \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"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,14 +11,17 @@ using namespace cv;
|
|||||||
|
|
||||||
void help()
|
void help()
|
||||||
{
|
{
|
||||||
cout << "This program shows the use of the Calonder point descriptor classifier"
|
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"
|
"SURF is used to detect interest points, Calonder is used to describe/match these points \n"
|
||||||
"Format:" << endl <<
|
"Usage: \n"
|
||||||
" classifier_file(to write) test_image file_with_train_images_filenames(txt)" <<
|
"./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"
|
||||||
" or" << endl <<
|
" --test_image=<image file for test, lena.jpg as default> \n"
|
||||||
" classifier_file(to read) test_image"
|
" [--train_container]=<txt file with train images filenames> \n"
|
||||||
"Using OpenCV version %s\n" << CV_VERSION << "\n"
|
"Example: \n"
|
||||||
<< endl;
|
" --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
|
* Generates random perspective transform of image
|
||||||
@ -144,18 +147,27 @@ void testCalonderClassifier( const string& classifierFilename, const string& img
|
|||||||
waitKey();
|
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();
|
help();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( argc == 4 )
|
if( !trainContainerFileName.empty())
|
||||||
trainCalonderClassifier( argv[1], argv[3] );
|
trainCalonderClassifier( classifierFileName.c_str(), trainContainerFileName.c_str() );
|
||||||
|
|
||||||
testCalonderClassifier( argv[1], argv[2] );
|
testCalonderClassifier( classifierFileName.c_str(), testImageFileName.c_str() );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ void help()
|
|||||||
"descriptor classifier"
|
"descriptor classifier"
|
||||||
"Usage:\n"
|
"Usage:\n"
|
||||||
"./find_obj_ferns [--object_filename]=<object_filename, box.png as default> \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)
|
int main(int argc, const char** argv)
|
||||||
|
@ -17,11 +17,10 @@ void help()
|
|||||||
{
|
{
|
||||||
printf( "This program demonstrated the use of the latentSVM detector.\n"
|
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"
|
"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"
|
"./latentsvmdetect [--image_filename]=<image_filename, cat.jpg as default> \n"
|
||||||
" [--model_filename] = <model_filename, cat.xml as default> \n"
|
" [--model_filename] = <model_filename, cat.xml as default> \n"
|
||||||
" [--threads_number] = <number of threads, -1 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");
|
" Press any key to quit.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@ void help()
|
|||||||
{
|
{
|
||||||
printf("\nThis program demonstrates the Maximal Extremal Region interest point detector.\n"
|
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"
|
"It finds the most stable (in size) dark and white regions as a threshold is increased.\n"
|
||||||
"\nCall:\n"
|
"\n Usage: \n"
|
||||||
"./mser_sample [--image_filename] <path_and_image_filename, default is 'puzzle.png'>\n\n");
|
"./mser_sample [--image_filename] <path_and_image_filename, default is 'puzzle.png'> \n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static CvScalar colors[] =
|
static CvScalar colors[] =
|
||||||
|
@ -18,9 +18,13 @@
|
|||||||
void help()
|
void help()
|
||||||
{
|
{
|
||||||
printf("\nThis program demonstrates the one way interest point descriptor found in features2d.hpp\n"
|
printf("\nThis program demonstrates the one way interest point descriptor found in features2d.hpp\n"
|
||||||
"Correspondences are drawn\n");
|
"Correspondences are drawn\n"
|
||||||
printf("Format: \n./one_way_sample <path_to_samples> <image1> <image2>\n");
|
"Usage: \n"
|
||||||
printf("For example: ./one_way_sample --path=../../../opencv/samples/c --first_image=scene_l.bmp --second_image=scene_r.bmp\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;
|
using namespace cv;
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
|
#include "opencv2/core/core.hpp"
|
||||||
#include "opencv2/ml/ml.hpp"
|
#include "opencv2/ml/ml.hpp"
|
||||||
#include "opencv2/core/core_c.h"
|
#include "opencv2/core/core_c.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace cv;
|
||||||
|
|
||||||
void help()
|
void help()
|
||||||
{
|
{
|
||||||
printf(
|
printf(
|
||||||
@ -12,10 +16,11 @@ void help()
|
|||||||
"CvRTrees rtrees;\n"
|
"CvRTrees rtrees;\n"
|
||||||
"CvERTrees ertrees;\n"
|
"CvERTrees ertrees;\n"
|
||||||
"CvGBTrees gbtrees;\n"
|
"CvGBTrees gbtrees;\n"
|
||||||
"Call:\n\t./tree_engine [-r <response_column>] [-c] <csv filename>\n"
|
"Usage: \n"
|
||||||
"where -r <response_column> specified the 0-based index of the response (0 by default)\n"
|
" ./tree_engine [--response_column]=<specified the 0-based index of the response, 0 as default> \n"
|
||||||
"-c specifies that the response is categorical (it's ordered by default) and\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\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");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, const char** argv)
|
||||||
{
|
{
|
||||||
if(argc < 2)
|
|
||||||
{
|
|
||||||
help();
|
help();
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
const char* filename = 0;
|
|
||||||
int response_idx = 0;
|
|
||||||
bool categorical_response = false;
|
|
||||||
|
|
||||||
for(int i = 1; i < argc; i++)
|
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())
|
||||||
{
|
{
|
||||||
if(strcmp(argv[i], "-r") == 0)
|
printf("\n Please, select value for --csv_filename key \n");
|
||||||
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();
|
help();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
printf("\nReading in %s...\n\n",filename);
|
printf("\nReading in %s...\n\n",filename.c_str());
|
||||||
CvDTree dtree;
|
CvDTree dtree;
|
||||||
CvBoost boost;
|
CvBoost boost;
|
||||||
CvRTrees rtrees;
|
CvRTrees rtrees;
|
||||||
@ -98,7 +93,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
CvTrainTestSplit spl( 0.5f );
|
CvTrainTestSplit spl( 0.5f );
|
||||||
|
|
||||||
if ( data.read_csv( filename ) == 0)
|
if ( data.read_csv( filename.c_str() ) == 0)
|
||||||
{
|
{
|
||||||
data.set_response_idx( response_idx );
|
data.set_response_idx( response_idx );
|
||||||
if(categorical_response)
|
if(categorical_response)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user