add new version of CommandLineParser. add empty docs

This commit is contained in:
AoD314
2012-09-07 13:24:48 +04:00
parent 6a112aa87a
commit 54a202b3d5
26 changed files with 855 additions and 665 deletions

View File

@@ -72,9 +72,9 @@ static void help()
//
const char *keys =
{
"{nf|nframes |300 |frames number}"
"{c |camera |false |use the camera or not}"
"{mf|movie_file|tree.avi |used movie video file}"
"{nf nframes |300 |frames number}"
"{c camera |false |use the camera or not}"
"{mf movie_file|tree.avi |used movie video file}"
};
int main(int argc, const char** argv)
{
@@ -82,7 +82,7 @@ int main(int argc, const char** argv)
CommandLineParser parser(argc, argv, keys);
int nframesToLearnBG = parser.get<int>("nf");
bool useCamera = parser.get<bool>("c");
bool useCamera = parser.has("c");
string filename = parser.get<string>("mf");
IplImage* rawImage = 0, *yuvImage = 0; //yuvImage is for codebook method
IplImage *ImaskCodeBook = 0,*ImaskCodeBookCC = 0;

View File

@@ -18,8 +18,8 @@ static void help()
const char* keys =
{
"{c |camera |true | use camera or not}"
"{fn|file_name|tree.avi | movie file }"
"{c camera | | use camera or not}"
"{fn file_name|tree.avi | movie file }"
};
//this is a sample for foreground detection functions
@@ -28,7 +28,7 @@ int main(int argc, const char** argv)
help();
CommandLineParser parser(argc, argv, keys);
bool useCamera = parser.get<bool>("camera");
bool useCamera = parser.has("camera");
string file = parser.get<string>("file_name");
VideoCapture cap;
bool update_bg_model = true;
@@ -37,7 +37,8 @@ int main(int argc, const char** argv)
cap.open(0);
else
cap.open(file.c_str());
parser.printParams();
parser.printMessage();
if( !cap.isOpened() )
{

View File

@@ -53,8 +53,8 @@ static void help()
const char* keys =
{
"{1| |box.png |the first image}"
"{2| |box_in_scene.png|the second image}"
"{@first_image | box.png | the first image}"
"{@second_image | box_in_scene.png | the second image}"
};
int main(int argc, const char ** argv)
@@ -62,8 +62,8 @@ int main(int argc, const char ** argv)
help();
CommandLineParser parser(argc, argv, keys);
string im1_name = parser.get<string>("1");
string im2_name = parser.get<string>("2");
string im1_name = parser.get<string>(1);
string im2_name = parser.get<string>(2);
Mat im1 = imread(im1_name, CV_LOAD_IMAGE_GRAYSCALE);
Mat im2 = imread(im2_name, CV_LOAD_IMAGE_GRAYSCALE);
@@ -72,7 +72,7 @@ int main(int argc, const char ** argv)
{
cout << "could not open one of the images..." << endl;
cout << "the cmd parameters have next current value: " << endl;
parser.printParams();
parser.printMessage();
return 1;
}

View File

@@ -64,7 +64,7 @@ static void help()
const char* keys =
{
"{1| | 0 | camera number}"
"{@camera_number| 0 | camera number}"
};
int main( int argc, const char** argv )
@@ -77,7 +77,7 @@ int main( int argc, const char** argv )
float hranges[] = {0,180};
const float* phranges = hranges;
CommandLineParser parser(argc, argv, keys);
int camNum = parser.get<int>("1");
int camNum = parser.get<int>(1);
cap.open(camNum);
@@ -86,7 +86,7 @@ int main( int argc, const char** argv )
help();
cout << "***Could not initialize capturing...***\n";
cout << "Current parameter's value: \n";
parser.printParams();
parser.printMessage();
return -1;
}

View File

@@ -19,8 +19,8 @@ static void help()
const char* keys =
{
"{1| |logo_in_clutter.png|image edge map }"
"{2| |logo.png |template edge map}"
"{@logo1 |logo_in_clutter.png |image edge map }"
"{@logo2 |logo.png |template edge map}"
};
int main( int argc, const char** argv )
@@ -29,8 +29,8 @@ int main( int argc, const char** argv )
help();
CommandLineParser parser(argc, argv, keys);
string image = parser.get<string>("1");
string templ = parser.get<string>("2");
string image = parser.get<string>(1);
string templ = parser.get<string>(2);
Mat img = imread(image.c_str(), 0);
Mat tpl = imread(templ.c_str(), 0);

View File

@@ -45,14 +45,14 @@ static void help()
const char* keys =
{
"{1| |stuff.jpg|image for converting to a grayscale}"
"{@image |stuff.jpg|image for converting to a grayscale}"
};
int main( int argc, const char** argv )
{
help();
CommandLineParser parser(argc, argv, keys);
string inputImage = parser.get<string>("1");
string inputImage = parser.get<string>(1);
img = imread(inputImage.c_str(), 0);
if(img.empty())

View File

@@ -62,7 +62,7 @@ static void help()
const char* keys =
{
"{1| |baboon.jpg|input image file}"
"{@image|baboon.jpg|input image file}"
};
int main( int argc, const char** argv )
@@ -70,7 +70,7 @@ int main( int argc, const char** argv )
help();
CommandLineParser parser(argc, argv, keys);
string inputImage = parser.get<string>("1");
string inputImage = parser.get<string>(1);
// Load the source image. HighGUI use.
image = imread( inputImage, 0 );

View File

@@ -17,14 +17,14 @@ static void help()
const char* keys =
{
"{1| |lena.jpg|input image file}"
"{@image|lena.jpg|input image file}"
};
int main(int argc, const char ** argv)
{
help();
CommandLineParser parser(argc, argv, keys);
string filename = parser.get<string>("1");
string filename = parser.get<string>(1);
Mat img = imread(filename.c_str(), CV_LOAD_IMAGE_GRAYSCALE);
if( img.empty() )

View File

@@ -104,14 +104,14 @@ static void help()
const char* keys =
{
"{1| |stuff.jpg|input image file}"
"{@image |stuff.jpg|input image file}"
};
int main( int argc, const char** argv )
{
help();
CommandLineParser parser(argc, argv, keys);
string filename = parser.get<string>("1");
string filename = parser.get<string>(1);
gray = imread(filename.c_str(), 0);
if(gray.empty())
{

View File

@@ -31,7 +31,7 @@ static void help()
const char* keys =
{
"{1| |fruits.jpg|input image name}"
"{@image |fruits.jpg|input image name}"
};
int main( int argc, const char** argv )
@@ -39,7 +39,7 @@ int main( int argc, const char** argv )
help();
CommandLineParser parser(argc, argv, keys);
string filename = parser.get<string>("1");
string filename = parser.get<string>(1);
image = imread(filename, 1);
if(image.empty())

View File

@@ -3,19 +3,23 @@
const char* keys =
{
"{ b |build |false | print complete build info }"
"{ h |help |false | print this help }"
"{ b build | | print complete build info }"
"{ h help | | print this help }"
};
int main(int argc, const char* argv[])
{
cv::CommandLineParser parser(argc, argv, keys);
if (parser.get<bool>("help"))
if (parser.has("help"))
{
parser.printParams();
parser.printMessage();
}
else if (parser.get<bool>("build"))
else if (!parser.check())
{
parser.printErrors();
}
else if (parser.has("build"))
{
std::cout << cv::getBuildInformation() << std::endl;
}
@@ -25,4 +29,4 @@ int main(int argc, const char* argv[])
}
return 0;
}
}

View File

@@ -64,20 +64,19 @@ static void openGlDrawCallback(void* userdata)
int main(int argc, const char* argv[])
{
const char* keys =
"{ l | left | | left image file name }"
"{ r | right | | right image file name }"
"{ i | intrinsic | | intrinsic camera parameters file name }"
"{ e | extrinsic | | extrinsic camera parameters file name }"
"{ d | ndisp | 256 | number of disparities }"
"{ s | scale | 1.0 | scale factor for point cloud }"
"{ h | help | false | print help message }";
"{ l left | | left image file name }"
"{ r right | | right image file name }"
"{ i intrinsic | | intrinsic camera parameters file name }"
"{ e extrinsic | | extrinsic camera parameters file name }"
"{ d ndisp | 256 | number of disparities }"
"{ s scale | 1.0 | scale factor for point cloud }"
"{ h help | | print help message }";
CommandLineParser cmd(argc, argv, keys);
if (cmd.get<bool>("help"))
if (cmd.has("help"))
{
cout << "Avaible options:" << endl;
cmd.printParams();
cmd.printMessage();
return 0;
}
@@ -88,11 +87,18 @@ int main(int argc, const char* argv[])
int ndisp = cmd.get<int>("ndisp");
double scale = cmd.get<double>("scale");
if (!cmd.check())
{
cmd.printErrors();
return 0;
}
if (left.empty() || right.empty())
{
cout << "Missed input images" << endl;
cout << "Avaible options:" << endl;
cmd.printParams();
cmd.printMessage();
return 0;
}
@@ -100,7 +106,7 @@ int main(int argc, const char* argv[])
{
cout << "Boss camera parameters must be specified" << endl;
cout << "Avaible options:" << endl;
cmd.printParams();
cmd.printMessage();
return 0;
}

View File

@@ -281,56 +281,56 @@ int main(int argc, const char **argv)
try
{
const char *keys =
"{ 1 | | | | }"
"{ m | model | affine | }"
"{ lp | lin-prog-motion-est | no | }"
"{ | subset | auto | }"
"{ | thresh | auto | }"
"{ | outlier-ratio | 0.5 | }"
"{ | min-inlier-ratio | 0.1 | }"
"{ | nkps | 1000 | }"
"{ | extra-kps | 0 | }"
"{ | local-outlier-rejection | no | }"
"{ sm | save-motions | no | }"
"{ lm | load-motions | no | }"
"{ r | radius | 15 | }"
"{ | stdev | auto | }"
"{ lps | lin-prog-stab | no | }"
"{ | lps-trim-ratio | auto | }"
"{ | lps-w1 | 1 | }"
"{ | lps-w2 | 10 | }"
"{ | lps-w3 | 100 | }"
"{ | lps-w4 | 100 | }"
"{ | deblur | no | }"
"{ | deblur-sens | 0.1 | }"
"{ et | est-trim | yes | }"
"{ t | trim-ratio | 0.1 | }"
"{ ic | incl-constr | no | }"
"{ bm | border-mode | replicate | }"
"{ | mosaic | no | }"
"{ ms | mosaic-stdev | 10.0 | }"
"{ mi | motion-inpaint | no | }"
"{ | mi-dist-thresh | 5.0 | }"
"{ ci | color-inpaint | no | }"
"{ | ci-radius | 2 | }"
"{ ws | wobble-suppress | no | }"
"{ | ws-period | 30 | }"
"{ | ws-model | homography | }"
"{ | ws-subset | auto | }"
"{ | ws-thresh | auto | }"
"{ | ws-outlier-ratio | 0.5 | }"
"{ | ws-min-inlier-ratio | 0.1 | }"
"{ | ws-nkps | 1000 | }"
"{ | ws-extra-kps | 0 | }"
"{ | ws-local-outlier-rejection | no | }"
"{ | ws-lp | no | }"
"{ sm2 | save-motions2 | no | }"
"{ lm2 | load-motions2 | no | }"
"{ gpu | | no }"
"{ o | output | stabilized.avi | }"
"{ | fps | auto | }"
"{ q | quiet | false | }"
"{ h | help | false | }";
"{ @1 | | }"
"{ m model | affine | }"
"{ lp lin-prog-motion-est | no | }"
"{ subset | auto | }"
"{ thresh | auto | }"
"{ outlier-ratio | 0.5 | }"
"{ min-inlier-ratio | 0.1 | }"
"{ nkps | 1000 | }"
"{ extra-kps | 0 | }"
"{ local-outlier-rejection | no | }"
"{ sm save-motions | no | }"
"{ lm load-motions | no | }"
"{ r radius | 15 | }"
"{ stdev | auto | }"
"{ lps lin-prog-stab | no | }"
"{ lps-trim-ratio | auto | }"
"{ lps-w1 | 1 | }"
"{ lps-w2 | 10 | }"
"{ lps-w3 | 100 | }"
"{ lps-w4 | 100 | }"
"{ deblur | no | }"
"{ deblur-sens | 0.1 | }"
"{ et est-trim | yes | }"
"{ t trim-ratio | 0.1 | }"
"{ ic incl-constr | no | }"
"{ bm border-mode | replicate | }"
"{ mosaic | no | }"
"{ ms mosaic-stdev | 10.0 | }"
"{ mi motion-inpaint | no | }"
"{ mi-dist-thresh | 5.0 | }"
"{ ci color-inpaint | no | }"
"{ ci-radius | 2 | }"
"{ ws wobble-suppress | no | }"
"{ ws-period | 30 | }"
"{ ws-model | homography | }"
"{ ws-subset | auto | }"
"{ ws-thresh | auto | }"
"{ ws-outlier-ratio | 0.5 | }"
"{ ws-min-inlier-ratio | 0.1 | }"
"{ ws-nkps | 1000 | }"
"{ ws-extra-kps | 0 | }"
"{ ws-local-outlier-rejection | no | }"
"{ ws-lp | no | }"
"{ sm2 save-motions2 | no | }"
"{ lm2 load-motions2 | no | }"
"{ gpu | no | }"
"{ o output | stabilized.avi | }"
"{ fps | auto | }"
"{ q quiet | | }"
"{ h help | | }";
CommandLineParser cmd(argc, argv, keys);
// parse command arguments

View File

@@ -21,20 +21,19 @@ enum Method
int main(int argc, const char** argv)
{
cv::CommandLineParser cmd(argc, argv,
"{ c | camera | false | use camera }"
"{ f | file | 768x576.avi | input video file }"
"{ m | method | mog | method (fgd, mog, mog2, vibe, gmg) }"
"{ h | help | false | print help message }");
"{ c camera | | use camera }"
"{ f file | 768x576.avi | input video file }"
"{ m method | mog | method (fgd, mog, mog2, vibe, gmg) }"
"{ h help | | print help message }");
if (cmd.get<bool>("help"))
if (cmd.has("help") || !cmd.check())
{
cout << "Usage : bgfg_segm [options]" << endl;
cout << "Avaible options:" << endl;
cmd.printParams();
cmd.printMessage();
cmd.printErrors();
return 0;
}
bool useCamera = cmd.get<bool>("camera");
bool useCamera = cmd.has("camera");
string file = cmd.get<string>("file");
string method = cmd.get<string>("method");

View File

@@ -25,24 +25,23 @@ int main(int argc, const char* argv[])
try
{
const char* keys =
"{ h | help | false | print help message }"
"{ l | left | | specify left image }"
"{ r | right | | specify right image }"
"{ s | scale | 0.8 | set pyramid scale factor }"
"{ a | alpha | 0.197 | set alpha }"
"{ g | gamma | 50.0 | set gamma }"
"{ i | inner | 10 | set number of inner iterations }"
"{ o | outer | 77 | set number of outer iterations }"
"{ si | solver | 10 | set number of basic solver iterations }"
"{ t | time_step | 0.1 | set frame interpolation time step }";
"{ h help | | print help message }"
"{ l left | | specify left image }"
"{ r right | | specify right image }"
"{ s scale | 0.8 | set pyramid scale factor }"
"{ a alpha | 0.197 | set alpha }"
"{ g gamma | 50.0 | set gamma }"
"{ i inner | 10 | set number of inner iterations }"
"{ o outer | 77 | set number of outer iterations }"
"{ si solver | 10 | set number of basic solver iterations }"
"{ t time_step | 0.1 | set frame interpolation time step }";
CommandLineParser cmd(argc, argv, keys);
if (cmd.get<bool>("help"))
if (cmd.has("help") || !cmd.check())
{
cout << "Usage: brox_optical_flow [options]" << endl;
cout << "Avaible options:" << endl;
cmd.printParams();
cmd.printMessage();
cmd.printErrors();
return 0;
}

View File

@@ -43,19 +43,19 @@ static void colorizeFlow(const Mat &u, const Mat &v, Mat &dst)
int main(int argc, char **argv)
{
CommandLineParser cmd(argc, argv,
"{ l | left | | specify left image }"
"{ r | right | | specify right image }"
"{ h | help | false | print help message }");
"{ l left | | specify left image }"
"{ r right | | specify right image }"
"{ h help | | print help message }");
if (cmd.get<bool>("help"))
cmd.about("Farneback's optical flow sample.");
if (cmd.has("help") || !cmd.check())
{
cout << "Farneback's optical flow sample.\n\n"
<< "Usage: farneback_optical_flow_gpu [arguments]\n\n"
<< "Arguments:\n";
cmd.printParams();
cmd.printMessage();
cmd.printErrors();
return 0;
}
string pathL = cmd.get<string>("left");
string pathR = cmd.get<string>("right");
if (pathL.empty()) cout << "Specify left image path\n";

View File

@@ -165,22 +165,23 @@ int main(int argc, const char* argv[])
redirectError(cvErrorCallback);
const char* keys =
"{ h | help | false | print help message }"
"{ f | filter | | filter for test }"
"{ w | workdir | | set working directory }"
"{ l | list | false | show all tests }"
"{ d | device | 0 | device id }"
"{ i | iters | 10 | iteration count }";
"{ h help | | print help message }"
"{ f filter | | filter for test }"
"{ w workdir | | set working directory }"
"{ l list | | show all tests }"
"{ d device | 0 | device id }"
"{ i iters | 10 | iteration count }";
CommandLineParser cmd(argc, argv, keys);
if (cmd.get<bool>("help"))
if (cmd.has("help") || !cmd.check())
{
cout << "Avaible options:" << endl;
cmd.printParams();
cmd.printMessage();
cmd.printErrors();
return 0;
}
int device = cmd.get<int>("device");
if (device < 0 || device >= num_devices)
{
@@ -198,7 +199,7 @@ int main(int argc, const char* argv[])
string filter = cmd.get<string>("filter");
string workdir = cmd.get<string>("workdir");
bool list = cmd.get<bool>("list");
bool list = cmd.has("list");
int iters = cmd.get<int>("iters");
if (!filter.empty())

View File

@@ -152,23 +152,22 @@ static void getFlowField(const Mat& u, const Mat& v, Mat& flowField)
int main(int argc, const char* argv[])
{
const char* keys =
"{ h | help | false | print help message }"
"{ l | left | | specify left image }"
"{ r | right | | specify right image }"
"{ gray | gray | false | use grayscale sources [PyrLK Sparse] }"
"{ win_size | win_size | 21 | specify windows size [PyrLK] }"
"{ max_level | max_level | 3 | specify max level [PyrLK] }"
"{ iters | iters | 30 | specify iterations count [PyrLK] }"
"{ points | points | 4000 | specify points count [GoodFeatureToTrack] }"
"{ min_dist | min_dist | 0 | specify minimal distance between points [GoodFeatureToTrack] }";
"{ h help | | print help message }"
"{ l left | | specify left image }"
"{ r right | | specify right image }"
"{ gray | | use grayscale sources [PyrLK Sparse] }"
"{ win_size | 21 | specify windows size [PyrLK] }"
"{ max_level | 3 | specify max level [PyrLK] }"
"{ iters | 30 | specify iterations count [PyrLK] }"
"{ points | 4000 | specify points count [GoodFeatureToTrack] }"
"{ min_dist | 0 | specify minimal distance between points [GoodFeatureToTrack] }";
CommandLineParser cmd(argc, argv, keys);
if (cmd.get<bool>("help"))
if (cmd.has("help") || !cmd.check())
{
cout << "Usage: pyrlk_optical_flow [options]" << endl;
cout << "Avaible options:" << endl;
cmd.printParams();
cmd.printMessage();
cmd.printErrors();
return 0;
}
@@ -181,7 +180,7 @@ int main(int argc, const char* argv[])
return -1;
}
bool useGray = cmd.get<bool>("gray");
bool useGray = cmd.has("gray");
int winSize = cmd.get<int>("win_size");
int maxLevel = cmd.get<int>("max_level");
int iters = cmd.get<int>("iters");