diff --git a/modules/core/doc/command_line_parser.rst b/modules/core/doc/command_line_parser.rst deleted file mode 100644 index c54e65b80..000000000 --- a/modules/core/doc/command_line_parser.rst +++ /dev/null @@ -1,101 +0,0 @@ -Command Line Parser -=================== - -.. highlight:: cpp - -CommandLineParser --------- -.. ocv:class:: CommandLineParser - -The CommandLineParser class is designed for command line arguments parsing - - - .. ocv:function:: CommandLineParser::CommandLineParser(int argc, const char * const argv[], const std::string keys) - - :param argc: - :param argv: - :param keys: - - .. ocv:function:: T CommandLineParser::get(const std::string& name, bool space_delete = true) - - :param name: - :param space_delete: - - .. ocv:function:: T CommandLineParser::get(int index, bool space_delete = true) - - :param index: - :param space_delete: - - .. ocv:function:: bool CommandLineParser::has(const std::string& name) - - :param name: - - .. ocv:function:: bool CommandLineParser::check() - - - .. ocv:function:: void CommandLineParser::about(std::string message) - - :param message: - - .. ocv:function:: void CommandLineParser::printMessage() - - .. ocv:function:: void CommandLineParser::printErrors() - - .. ocv:function:: std::string CommandLineParser::getPathToApplication() - - -The sample below demonstrates how to use CommandLineParser: - -:: - - CommandLineParser parser(argc, argv, keys); - parser.about("Application name v1.0.0"); - - if (parser.has("help")) - { - parser.printMessage(); - return 0; - } - - int N = parser.get("N"); - double fps = parser.get("fps"); - std::string path = parser.get("path"); - - use_time_stamp = parser.has("timestamp"); - - std::string img1 = parser.get(0); - std::string img2 = parser.get(1); - - int repeat = parser.get(2); - - if (!parser.check()) - { - parser.printErrors(); - return 0; - } - -Syntax: - -:: - - const std::string keys = - "{help h usage ? | | print this message }" - "{@image1 | | image1 for compare }" - "{@image2 | | image2 for compare }" - "{@repeat |1 | number }" - "{path |. | path to file }" - "{fps | -1.0 | fps for output video }" - "{N count |100 | count of objects }" - "{ts timestamp | | use time stamp }" - ; - -Use: - -:: - - # ./app -N=200 1.png 2.jpg 19 -ts - - # ./app -fps=aaa - ERRORS: - Exception: can not convert: [aaa] to [double] - diff --git a/modules/core/doc/core.rst b/modules/core/doc/core.rst index 90caeebc7..7eb4e3e63 100644 --- a/modules/core/doc/core.rst +++ b/modules/core/doc/core.rst @@ -6,7 +6,6 @@ core. The Core Functionality :maxdepth: 2 basic_structures - command_line_parser old_basic_structures dynamic_structures operations_on_arrays diff --git a/modules/ts/src/ts_perf.cpp b/modules/ts/src/ts_perf.cpp index 6f14104a1..8cf617e09 100644 --- a/modules/ts/src/ts_perf.cpp +++ b/modules/ts/src/ts_perf.cpp @@ -11,25 +11,25 @@ unsigned int TestBase::iterationsLimitDefault = (unsigned int)(-1); int64 TestBase::_timeadjustment = 0; const std::string command_line_keys = - "{ perf_max_outliers |8 |percent of allowed outliers}" - "{ perf_min_samples |10 |minimal required numer of samples}" - "{ perf_force_samples |100 |force set maximum number of samples for all tests}" - "{ perf_seed |809564 |seed for random numbers generator}" - "{ perf_threads |-1 |the number of worker threads, if parallel execution is enabled}" - "{ perf_write_sanity | |allow to create new records for sanity checks}" + "{ |perf_max_outliers |8 |percent of allowed outliers}" + "{ |perf_min_samples |10 |minimal required numer of samples}" + "{ |perf_force_samples |100 |force set maximum number of samples for all tests}" + "{ |perf_seed |809564 |seed for random numbers generator}" + "{ |perf_threads |-1 |the number of worker threads, if parallel execution is enabled}" + "{ |perf_write_sanity | |allow to create new records for sanity checks}" #ifdef ANDROID - "{ perf_time_limit |6.0 |default time limit for a single test (in seconds)}" - "{ perf_affinity_mask |0 |set affinity mask for the main thread}" - "{ perf_log_power_checkpoints | |additional xml logging for power measurement}" + "{ |perf_time_limit |6.0 |default time limit for a single test (in seconds)}" + "{ |perf_affinity_mask |0 |set affinity mask for the main thread}" + "{ |perf_log_power_checkpoints | |additional xml logging for power measurement}" #else - "{ perf_time_limit |3.0 |default time limit for a single test (in seconds)}" + "{ |perf_time_limit |3.0 |default time limit for a single test (in seconds)}" #endif - "{ perf_max_deviation |1.0 |}" - "{ help h | |print help info}" + "{ |perf_max_deviation |1.0 |}" + "{h |help | |print help info}" #ifdef HAVE_CUDA - "{ perf_run_cpu |false |run GPU performance tests for analogical CPU functions}" - "{ perf_cuda_device |0 |run GPU test suite onto specific CUDA capable device}" - "{ perf_cuda_info_only |false |print an information about system and an available CUDA devices and then exit.}" + "{ |perf_run_cpu |false |run GPU performance tests for analogical CPU functions}" + "{ |perf_cuda_device |0 |run GPU test suite onto specific CUDA capable device}" + "{ |perf_cuda_info_only |false |print an information about system and an available CUDA devices and then exit.}" #endif ; @@ -640,10 +640,11 @@ performance_metrics::performance_metrics() void TestBase::Init(int argc, const char* const argv[]) { - cv::CommandLineParser args(argc, argv, command_line_keys); - if (args.has("help")) + cv::CommandLineParser args(argc, argv, command_line_keys.c_str()); + if (args.get("help")) { - args.printMessage(); + args.printParams(); + printf("\n\n"); return; } @@ -652,24 +653,24 @@ void TestBase::Init(int argc, const char* const argv[]) param_max_outliers = std::min(100., std::max(0., args.get("perf_max_outliers"))); param_min_samples = std::max(1u, args.get("perf_min_samples")); param_max_deviation = std::max(0., args.get("perf_max_deviation")); - param_seed = args.get("perf_seed"); + param_seed = args.get("perf_seed"); param_time_limit = std::max(0., args.get("perf_time_limit")); param_force_samples = args.get("perf_force_samples"); - param_write_sanity = args.has("perf_write_sanity"); + param_write_sanity = args.get("perf_write_sanity"); param_threads = args.get("perf_threads"); #ifdef ANDROID param_affinity_mask = args.get("perf_affinity_mask"); - log_power_checkpoints = args.has("perf_log_power_checkpoints"); + log_power_checkpoints = args.get("perf_log_power_checkpoints"); #endif #ifdef HAVE_CUDA - bool printOnly = args.has("perf_cuda_info_only"); + bool printOnly = args.get("perf_cuda_info_only"); if (printOnly) exit(0); - param_run_cpu = args.has("perf_run_cpu"); + param_run_cpu = args.get("perf_run_cpu"); param_cuda_device = std::max(0, std::min(cv::gpu::getCudaEnabledDeviceCount(), args.get("perf_cuda_device"))); if (param_run_cpu) @@ -689,11 +690,11 @@ void TestBase::Init(int argc, const char* const argv[]) } #endif - if (!args.check()) - { - args.printErrors(); - return; - } +// if (!args.check()) +// { +// args.printErrors(); +// return; +// } timeLimitDefault = param_time_limit == 0.0 ? 1 : (int64)(param_time_limit * cv::getTickFrequency()); iterationsLimitDefault = param_force_samples == 0 ? (unsigned)(-1) : param_force_samples; diff --git a/samples/c/bgfg_codebook.cpp b/samples/c/bgfg_codebook.cpp index 3054e9971..2b157283d 100644 --- a/samples/c/bgfg_codebook.cpp +++ b/samples/c/bgfg_codebook.cpp @@ -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("nf"); - bool useCamera = parser.has("c"); + bool useCamera = parser.get("c"); string filename = parser.get("mf"); IplImage* rawImage = 0, *yuvImage = 0; //yuvImage is for codebook method IplImage *ImaskCodeBook = 0,*ImaskCodeBookCC = 0; diff --git a/samples/cpp/bgfg_segm.cpp b/samples/cpp/bgfg_segm.cpp index 72566ea8f..ffb238292 100644 --- a/samples/cpp/bgfg_segm.cpp +++ b/samples/cpp/bgfg_segm.cpp @@ -18,8 +18,8 @@ static void help() const char* keys = { - "{c camera | | use camera or not}" - "{fn file_name|tree.avi | movie file }" + "{c |camera |true | 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.has("camera"); + bool useCamera = parser.get("camera"); string file = parser.get("file_name"); VideoCapture cap; bool update_bg_model = true; @@ -37,8 +37,7 @@ int main(int argc, const char** argv) cap.open(0); else cap.open(file.c_str()); - - parser.printMessage(); + parser.printParams(); if( !cap.isOpened() ) { diff --git a/samples/cpp/brief_match_test.cpp b/samples/cpp/brief_match_test.cpp index b4c81ee24..9223f2131 100644 --- a/samples/cpp/brief_match_test.cpp +++ b/samples/cpp/brief_match_test.cpp @@ -53,8 +53,8 @@ static void help() const char* keys = { - "{@first_image | box.png | the first image}" - "{@second_image | box_in_scene.png | the second image}" + "{1| |box.png |the first image}" + "{2| |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(1); - string im2_name = parser.get(2); + string im1_name = parser.get("1"); + string im2_name = parser.get("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.printMessage(); + parser.printParams(); return 1; } diff --git a/samples/cpp/camshiftdemo.cpp b/samples/cpp/camshiftdemo.cpp index f9f393f9e..0b17239ed 100644 --- a/samples/cpp/camshiftdemo.cpp +++ b/samples/cpp/camshiftdemo.cpp @@ -64,7 +64,7 @@ static void help() const char* keys = { - "{@camera_number| 0 | camera number}" + "{1| | 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(1); + int camNum = parser.get("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.printMessage(); + parser.printParams(); return -1; } diff --git a/samples/cpp/chamfer.cpp b/samples/cpp/chamfer.cpp index 906c9542a..4be87cf76 100644 --- a/samples/cpp/chamfer.cpp +++ b/samples/cpp/chamfer.cpp @@ -19,8 +19,8 @@ static void help() const char* keys = { - "{@logo1 |logo_in_clutter.png |image edge map }" - "{@logo2 |logo.png |template edge map}" + "{1| |logo_in_clutter.png|image edge map }" + "{2| |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(1); - string templ = parser.get(2); + string image = parser.get("1"); + string templ = parser.get("2"); Mat img = imread(image.c_str(), 0); Mat tpl = imread(templ.c_str(), 0); diff --git a/samples/cpp/connected_components.cpp b/samples/cpp/connected_components.cpp index c915bcda4..b83660d0c 100644 --- a/samples/cpp/connected_components.cpp +++ b/samples/cpp/connected_components.cpp @@ -45,14 +45,14 @@ static void help() const char* keys = { - "{@image |stuff.jpg|image for converting to a grayscale}" + "{1| |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(1); + string inputImage = parser.get("1"); img = imread(inputImage.c_str(), 0); if(img.empty()) diff --git a/samples/cpp/demhist.cpp b/samples/cpp/demhist.cpp index d982ecb33..59ecf25aa 100644 --- a/samples/cpp/demhist.cpp +++ b/samples/cpp/demhist.cpp @@ -62,7 +62,7 @@ static void help() const char* keys = { - "{@image|baboon.jpg|input image file}" + "{1| |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(1); + string inputImage = parser.get("1"); // Load the source image. HighGUI use. image = imread( inputImage, 0 ); diff --git a/samples/cpp/dft.cpp b/samples/cpp/dft.cpp index 62dba20d3..dbbc2cc77 100644 --- a/samples/cpp/dft.cpp +++ b/samples/cpp/dft.cpp @@ -17,14 +17,14 @@ static void help() const char* keys = { - "{@image|lena.jpg|input image file}" + "{1| |lena.jpg|input image file}" }; int main(int argc, const char ** argv) { help(); CommandLineParser parser(argc, argv, keys); - string filename = parser.get(1); + string filename = parser.get("1"); Mat img = imread(filename.c_str(), CV_LOAD_IMAGE_GRAYSCALE); if( img.empty() ) diff --git a/samples/cpp/distrans.cpp b/samples/cpp/distrans.cpp index 5e805775c..4e3c3a2b0 100644 --- a/samples/cpp/distrans.cpp +++ b/samples/cpp/distrans.cpp @@ -104,14 +104,14 @@ static void help() const char* keys = { - "{@image |stuff.jpg|input image file}" + "{1| |stuff.jpg|input image file}" }; int main( int argc, const char** argv ) { help(); CommandLineParser parser(argc, argv, keys); - string filename = parser.get(1); + string filename = parser.get("1"); gray = imread(filename.c_str(), 0); if(gray.empty()) { diff --git a/samples/cpp/edge.cpp b/samples/cpp/edge.cpp index 8deda898b..6ff30a2cf 100644 --- a/samples/cpp/edge.cpp +++ b/samples/cpp/edge.cpp @@ -31,7 +31,7 @@ static void help() const char* keys = { - "{@image |fruits.jpg|input image name}" + "{1| |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(1); + string filename = parser.get("1"); image = imread(filename, 1); if(image.empty()) diff --git a/samples/cpp/opencv_version.cpp b/samples/cpp/opencv_version.cpp index 635f19151..5eb4bcc7b 100644 --- a/samples/cpp/opencv_version.cpp +++ b/samples/cpp/opencv_version.cpp @@ -3,23 +3,19 @@ const char* keys = { - "{ b build | | print complete build info }" - "{ h help | | print this help }" + "{ b |build |false | print complete build info }" + "{ h |help |false | print this help }" }; int main(int argc, const char* argv[]) { cv::CommandLineParser parser(argc, argv, keys); - if (parser.has("help")) + if (parser.get("help")) { - parser.printMessage(); + parser.printParams(); } - else if (!parser.check()) - { - parser.printErrors(); - } - else if (parser.has("build")) + else if (parser.get("build")) { std::cout << cv::getBuildInformation() << std::endl; } @@ -29,4 +25,4 @@ int main(int argc, const char* argv[]) } return 0; -} +} \ No newline at end of file diff --git a/samples/cpp/point_cloud.cpp b/samples/cpp/point_cloud.cpp index 998fafc79..a9dda17ee 100644 --- a/samples/cpp/point_cloud.cpp +++ b/samples/cpp/point_cloud.cpp @@ -64,19 +64,20 @@ 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 | | 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 | false | print help message }"; CommandLineParser cmd(argc, argv, keys); - if (cmd.has("help")) + if (cmd.get("help")) { - cmd.printMessage(); + cout << "Avaible options:" << endl; + cmd.printParams(); return 0; } @@ -87,18 +88,11 @@ int main(int argc, const char* argv[]) int ndisp = cmd.get("ndisp"); double scale = cmd.get("scale"); - if (!cmd.check()) - { - cmd.printErrors(); - return 0; - } - - if (left.empty() || right.empty()) { cout << "Missed input images" << endl; cout << "Avaible options:" << endl; - cmd.printMessage(); + cmd.printParams(); return 0; } @@ -106,7 +100,7 @@ int main(int argc, const char* argv[]) { cout << "Boss camera parameters must be specified" << endl; cout << "Avaible options:" << endl; - cmd.printMessage(); + cmd.printParams(); return 0; } diff --git a/samples/cpp/videostab.cpp b/samples/cpp/videostab.cpp index ee5bd1f3b..7a0ef56f2 100644 --- a/samples/cpp/videostab.cpp +++ b/samples/cpp/videostab.cpp @@ -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 | | }" - "{ h help | | }"; + "{ 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 | }"; CommandLineParser cmd(argc, argv, keys); // parse command arguments diff --git a/samples/gpu/bgfg_segm.cpp b/samples/gpu/bgfg_segm.cpp index 9456b15e8..4e4c52096 100644 --- a/samples/gpu/bgfg_segm.cpp +++ b/samples/gpu/bgfg_segm.cpp @@ -21,19 +21,20 @@ enum Method int main(int argc, const char** argv) { cv::CommandLineParser cmd(argc, argv, - "{ 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 }"); + "{ 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 }"); - if (cmd.has("help") || !cmd.check()) + if (cmd.get("help")) { - cmd.printMessage(); - cmd.printErrors(); + cout << "Usage : bgfg_segm [options]" << endl; + cout << "Avaible options:" << endl; + cmd.printParams(); return 0; } - bool useCamera = cmd.has("camera"); + bool useCamera = cmd.get("camera"); string file = cmd.get("file"); string method = cmd.get("method"); diff --git a/samples/gpu/brox_optical_flow.cpp b/samples/gpu/brox_optical_flow.cpp index 76339c9bf..8ff0df490 100644 --- a/samples/gpu/brox_optical_flow.cpp +++ b/samples/gpu/brox_optical_flow.cpp @@ -25,23 +25,24 @@ int main(int argc, const char* argv[]) try { const char* keys = - "{ 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 }"; + "{ 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 }"; CommandLineParser cmd(argc, argv, keys); - if (cmd.has("help") || !cmd.check()) + if (cmd.get("help")) { - cmd.printMessage(); - cmd.printErrors(); + cout << "Usage: brox_optical_flow [options]" << endl; + cout << "Avaible options:" << endl; + cmd.printParams(); return 0; } diff --git a/samples/gpu/farneback_optical_flow.cpp b/samples/gpu/farneback_optical_flow.cpp index 77ee49e1a..e33c07e4d 100644 --- a/samples/gpu/farneback_optical_flow.cpp +++ b/samples/gpu/farneback_optical_flow.cpp @@ -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 | | print help message }"); + "{ l | left | | specify left image }" + "{ r | right | | specify right image }" + "{ h | help | false | print help message }"); - cmd.about("Farneback's optical flow sample."); - if (cmd.has("help") || !cmd.check()) + if (cmd.get("help")) { - cmd.printMessage(); - cmd.printErrors(); + cout << "Farneback's optical flow sample.\n\n" + << "Usage: farneback_optical_flow_gpu [arguments]\n\n" + << "Arguments:\n"; + cmd.printParams(); return 0; } - string pathL = cmd.get("left"); string pathR = cmd.get("right"); if (pathL.empty()) cout << "Specify left image path\n"; diff --git a/samples/gpu/performance/performance.cpp b/samples/gpu/performance/performance.cpp index 2f5448b49..1cb917605 100644 --- a/samples/gpu/performance/performance.cpp +++ b/samples/gpu/performance/performance.cpp @@ -165,23 +165,22 @@ int main(int argc, const char* argv[]) redirectError(cvErrorCallback); const char* keys = - "{ 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 }"; + "{ 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 }"; CommandLineParser cmd(argc, argv, keys); - if (cmd.has("help") || !cmd.check()) + if (cmd.get("help")) { - cmd.printMessage(); - cmd.printErrors(); + cout << "Avaible options:" << endl; + cmd.printParams(); return 0; } - int device = cmd.get("device"); if (device < 0 || device >= num_devices) { @@ -199,7 +198,7 @@ int main(int argc, const char* argv[]) string filter = cmd.get("filter"); string workdir = cmd.get("workdir"); - bool list = cmd.has("list"); + bool list = cmd.get("list"); int iters = cmd.get("iters"); if (!filter.empty()) diff --git a/samples/gpu/pyrlk_optical_flow.cpp b/samples/gpu/pyrlk_optical_flow.cpp index 5ebf85937..5bff8f94f 100644 --- a/samples/gpu/pyrlk_optical_flow.cpp +++ b/samples/gpu/pyrlk_optical_flow.cpp @@ -152,22 +152,23 @@ static void getFlowField(const Mat& u, const Mat& v, Mat& flowField) int main(int argc, const char* argv[]) { const char* keys = - "{ 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] }"; + "{ 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] }"; CommandLineParser cmd(argc, argv, keys); - if (cmd.has("help") || !cmd.check()) + if (cmd.get("help")) { - cmd.printMessage(); - cmd.printErrors(); + cout << "Usage: pyrlk_optical_flow [options]" << endl; + cout << "Avaible options:" << endl; + cmd.printParams(); return 0; } @@ -180,7 +181,7 @@ int main(int argc, const char* argv[]) return -1; } - bool useGray = cmd.has("gray"); + bool useGray = cmd.get("gray"); int winSize = cmd.get("win_size"); int maxLevel = cmd.get("max_level"); int iters = cmd.get("iters");